sonamu 0.12.0 → 0.13.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/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/ai/agents/agent.js +2 -3
- package/dist/ai/agents/index.js +1 -2
- package/dist/ai/index.js +1 -2
- package/dist/ai/providers/rtzr/api.js +1 -2
- package/dist/ai/providers/rtzr/error.js +2 -3
- package/dist/ai/providers/rtzr/model.js +1 -2
- package/dist/ai/providers/rtzr/options.js +1 -2
- package/dist/ai/providers/rtzr/provider.js +1 -2
- package/dist/ai/providers/rtzr/utils.js +1 -2
- package/dist/api/base-frame.js +4 -4
- package/dist/api/caster.d.ts +1 -1
- package/dist/api/caster.d.ts.map +1 -1
- package/dist/api/caster.js +9 -9
- package/dist/api/code-converters.js +6 -5
- package/dist/api/config.d.ts +1 -1
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +2 -3
- package/dist/api/context.d.ts +2 -3
- package/dist/api/context.d.ts.map +1 -1
- package/dist/api/context.js +2 -3
- package/dist/api/decorators.js +2 -3
- package/dist/api/http-validator.js +2 -3
- package/dist/api/index.js +8 -3
- package/dist/api/secret.js +1 -2
- package/dist/api/sonamu.d.ts +3 -5
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +19 -18
- package/dist/api/validator.js +1 -2
- package/dist/api/websocket-helpers.js +2 -3
- package/dist/auth/audit-log/builders.js +1 -2
- package/dist/auth/audit-log/client-ip.js +2 -3
- package/dist/auth/audit-log/events.js +1 -2
- package/dist/auth/audit-log/plugin.d.ts.map +1 -1
- package/dist/auth/audit-log/plugin.js +2 -3
- package/dist/auth/audit-log-ingestor.js +2 -3
- package/dist/auth/auth-generator.js +2 -3
- package/dist/auth/better-auth-entities.js +1 -2
- package/dist/auth/better-auth-request.js +2 -3
- package/dist/auth/index.js +2 -3
- package/dist/auth/knex-adapter.js +2 -3
- package/dist/auth/plugins/entity-definitions/admin.js +1 -2
- package/dist/auth/plugins/entity-definitions/anonymous.js +1 -2
- package/dist/auth/plugins/entity-definitions/api-key.js +1 -2
- package/dist/auth/plugins/entity-definitions/audit-log.js +1 -2
- package/dist/auth/plugins/entity-definitions/index.js +1 -2
- package/dist/auth/plugins/entity-definitions/jwt.js +1 -2
- package/dist/auth/plugins/entity-definitions/organization.js +1 -2
- package/dist/auth/plugins/entity-definitions/passkey.js +1 -2
- package/dist/auth/plugins/entity-definitions/phone-number.js +1 -2
- package/dist/auth/plugins/entity-definitions/sso.js +1 -2
- package/dist/auth/plugins/entity-definitions/two-factor.js +1 -2
- package/dist/auth/plugins/entity-definitions/username.js +1 -2
- package/dist/auth/plugins/wrappers/admin.d.ts +33 -32
- package/dist/auth/plugins/wrappers/admin.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/admin.js +2 -3
- package/dist/auth/plugins/wrappers/anonymous.js +2 -3
- package/dist/auth/plugins/wrappers/api-key.js +2 -3
- package/dist/auth/plugins/wrappers/jwt.js +2 -3
- package/dist/auth/plugins/wrappers/organization.js +2 -3
- package/dist/auth/plugins/wrappers/passkey.js +2 -3
- package/dist/auth/plugins/wrappers/phone-number.d.ts +43 -1
- package/dist/auth/plugins/wrappers/phone-number.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/phone-number.js +2 -3
- package/dist/auth/plugins/wrappers/sso.d.ts +138 -187
- package/dist/auth/plugins/wrappers/sso.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/sso.js +1 -2
- package/dist/auth/plugins/wrappers/two-factor.d.ts +51 -10
- package/dist/auth/plugins/wrappers/two-factor.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/two-factor.js +2 -3
- package/dist/auth/plugins/wrappers/username.d.ts +39 -5
- package/dist/auth/plugins/wrappers/username.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/username.js +2 -3
- package/dist/bin/build-config.js +5 -5
- package/dist/bin/compiler-policy.js +2 -3
- package/dist/bin/fixture.js +7 -5
- package/dist/bin/hmr-hook-register.js +1 -2
- package/dist/bin/migrate-targets.js +2 -3
- package/dist/bin/test-command.js +2 -3
- package/dist/bin/ts-loader-register.js +2 -3
- package/dist/bin/ts-loader-registration.js +2 -3
- package/dist/bin/typecheck-web.js +2 -3
- package/dist/cache/cache-manager.js +1 -2
- package/dist/cache/decorator.js +2 -3
- package/dist/cache/drivers.js +1 -2
- package/dist/cache/index.js +2 -3
- package/dist/cache-control/cache-control.js +1 -2
- package/dist/code-formatting/index.js +2 -3
- package/dist/code-formatting/oxfmt.js +2 -3
- package/dist/code-formatting/oxlint.js +2 -3
- package/dist/compress/compress.js +1 -2
- package/dist/compress/index.js +2 -2
- package/dist/compress/types.d.ts +1 -1
- package/dist/compress/types.d.ts.map +1 -1
- package/dist/cone/cone-generator.js +2 -3
- package/dist/database/_batch_update.js +1 -2
- package/dist/database/base-model.js +4 -4
- package/dist/database/db.js +4 -4
- package/dist/database/knex.js +2 -3
- package/dist/database/puri-wrapper.js +2 -3
- package/dist/database/puri.js +23 -22
- package/dist/database/puri.types.js +1 -2
- package/dist/database/transaction-context.js +1 -2
- package/dist/database/upsert-builder.js +2 -3
- package/dist/dict/en.js +2 -3
- package/dist/dict/index.js +3 -3
- package/dist/dict/ko.js +2 -3
- package/dist/dict/rc-keys.js +1 -2
- package/dist/dict/sd.js +2 -3
- package/dist/dict/sonamu-dictionary.js +7 -6
- package/dist/dict/utils.js +2 -3
- package/dist/entity/entity-manager.d.ts +66 -66
- package/dist/entity/entity-manager.js +4 -4
- package/dist/entity/entity-template-cone.js +2 -3
- package/dist/entity/entity.js +21 -18
- package/dist/env.js +1 -2
- package/dist/exceptions/error-handler.d.ts.map +1 -1
- package/dist/exceptions/error-handler.js +2 -3
- package/dist/exceptions/so-exceptions.js +2 -3
- package/dist/filter/index.js +3 -2
- package/dist/filter/types.js +1 -2
- package/dist/filter/utils.js +7 -6
- package/dist/index.js +39 -5
- package/dist/logger/category.js +2 -3
- package/dist/logger/configure.js +5 -5
- package/dist/migration/code-generation.js +23 -16
- package/dist/migration/index-where-predicate.js +2 -3
- package/dist/migration/migration-set.js +2 -3
- package/dist/migration/migrator.js +2 -3
- package/dist/migration/postgresql-schema-reader.js +6 -9
- package/dist/migration/slack-confirm.js +2 -3
- package/dist/naite/naite-reporter.js +2 -3
- package/dist/naite/naite.js +10 -8
- package/dist/runtime-type.js +2 -3
- package/dist/ssr/hmr-opt-out.js +1 -2
- package/dist/ssr/index.js +7 -4
- package/dist/ssr/registry.js +1 -2
- package/dist/ssr/renderer.js +2 -3
- package/dist/storage/base-file.js +1 -2
- package/dist/storage/buffered-file.js +2 -3
- package/dist/storage/drivers.js +1 -2
- package/dist/storage/index.js +2 -3
- package/dist/storage/s3-driver.js +1 -2
- package/dist/storage/storage-manager.js +2 -3
- package/dist/storage/uploaded-file.js +2 -3
- package/dist/stream/__tests__/ws-test-helpers.js +2 -3
- package/dist/stream/index.js +11 -2
- package/dist/stream/sse.js +1 -2
- package/dist/stream/ws-audience-resolver.js +2 -3
- package/dist/stream/ws-audience.js +1 -2
- package/dist/stream/ws-cluster-bus.js +1 -2
- package/dist/stream/ws-delivery.js +2 -3
- package/dist/stream/ws-frame.js +1 -2
- package/dist/stream/ws-local-connection-store.js +2 -3
- package/dist/stream/ws-presence-index.js +1 -2
- package/dist/stream/ws-presence-store.js +2 -3
- package/dist/stream/ws-registry.js +2 -3
- package/dist/stream/ws-session-id.js +1 -2
- package/dist/stream/ws-telemetry-memory.js +3 -4
- package/dist/stream/ws-telemetry-trace.js +1 -2
- package/dist/stream/ws-telemetry.js +2 -3
- package/dist/stream/ws.js +2 -3
- package/dist/syncer/api-parser.js +2 -3
- package/dist/syncer/checksum.js +4 -4
- package/dist/syncer/code-generator.js +4 -4
- package/dist/syncer/entity-operations.js +2 -3
- package/dist/syncer/event-batcher.js +1 -2
- package/dist/syncer/file-copy.js +2 -3
- package/dist/syncer/file-patterns.js +2 -3
- package/dist/syncer/file-tracking.js +2 -3
- package/dist/syncer/filesystem-dependencies.js +1 -2
- package/dist/syncer/index.js +8 -2
- package/dist/syncer/module-loader.js +8 -6
- package/dist/syncer/syncer-actions.js +8 -7
- package/dist/syncer/syncer.js +13 -8
- package/dist/syncer/watcher.js +2 -3
- package/dist/tasks/decorator.js +1 -2
- package/dist/tasks/step-wrapper.js +2 -3
- package/dist/tasks/workflow-manager.js +2 -3
- package/dist/template/entity-converter.js +17 -16
- package/dist/template/helpers.js +2 -3
- package/dist/template/implementations/entity.template.js +2 -3
- package/dist/template/implementations/entry-server.template.js +2 -3
- package/dist/template/implementations/generated.template.js +2 -3
- package/dist/template/implementations/generated_http.template.js +6 -6
- package/dist/template/implementations/generated_sso.template.js +2 -3
- package/dist/template/implementations/http_validators.template.js +2 -3
- package/dist/template/implementations/init_types.template.js +2 -3
- package/dist/template/implementations/model.template.js +4 -4
- package/dist/template/implementations/model_test.template.js +2 -3
- package/dist/template/implementations/queries.template.js +2 -3
- package/dist/template/implementations/sd.template.js +2 -3
- package/dist/template/implementations/services.template.js +2 -3
- package/dist/template/implementations/view_form.template.js +12 -9
- package/dist/template/implementations/view_id_all_select.template.js +2 -3
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +19 -17
- package/dist/template/implementations/view_search_input.template.js +2 -3
- package/dist/template/index.js +9 -3
- package/dist/template/template-manager.js +2 -3
- package/dist/template/template-types.js +1 -2
- package/dist/template/template.js +2 -3
- package/dist/template/zod-converter.js +54 -47
- package/dist/testing/_relation-graph.js +2 -3
- package/dist/testing/bootstrap.js +2 -3
- package/dist/testing/data-explorer.js +2 -3
- package/dist/testing/dev-test-routes.js +2 -3
- package/dist/testing/dev-vitest-manager.js +15 -12
- package/dist/testing/faker-mappings.js +1 -2
- package/dist/testing/filesystem.js +2 -3
- package/dist/testing/fixture-generator.js +2 -3
- package/dist/testing/fixture-loader.js +1 -2
- package/dist/testing/fixture-manager.js +12 -9
- package/dist/testing/global-setup.js +5 -5
- package/dist/testing/index.js +6 -3
- package/dist/testing/naite-vitest-reporter.js +1 -2
- package/dist/testing/parallel-db-manager.js +2 -3
- package/dist/testing/vitest-helpers.js +2 -3
- package/dist/tooling/__tests__/helpers/sonamu-test-root.js +2 -3
- package/dist/tooling/cdd-service.js +1 -2
- package/dist/tooling/cli-tooling.js +1 -2
- package/dist/tooling/fixture-service.js +1 -2
- package/dist/tooling/index.js +1 -2
- package/dist/tooling/test-run-client.js +2 -3
- package/dist/tsdown.api.config.js +1 -2
- package/dist/types/types.js +2 -3
- package/dist/ui/ai-api.d.ts.map +1 -1
- package/dist/ui/ai-api.js +4 -5
- package/dist/ui/ai-client.d.ts +2 -2
- package/dist/ui/ai-client.d.ts.map +1 -1
- package/dist/ui/ai-client.js +9 -8
- package/dist/ui/api.d.ts.map +1 -1
- package/dist/ui/api.js +11 -8
- package/dist/ui/async-route.js +1 -2
- package/dist/ui/cdd-service.js +22 -21
- package/dist/ui/migrations-api.js +6 -5
- package/dist/ui-web/assets/index-QDMyy31K.js +180 -0
- package/dist/ui-web/assets/index-dV7akMFB.css +1 -0
- package/dist/ui-web/index.html +2 -2
- package/dist/utils/async-utils.js +1 -2
- package/dist/utils/class-name.js +1 -2
- package/dist/utils/console-util.js +1 -2
- package/dist/utils/controller.js +2 -3
- package/dist/utils/esm-utils.js +1 -2
- package/dist/utils/fs-utils.js +2 -3
- package/dist/utils/lodash-able.js +1 -2
- package/dist/utils/model.js +1 -2
- package/dist/utils/object-utils.js +2 -3
- package/dist/utils/path-utils.js +2 -3
- package/dist/utils/process-utils.js +2 -3
- package/dist/utils/runtime-value.js +1 -2
- package/dist/utils/sql-parser.js +2 -3
- package/dist/utils/type-utils.js +8 -8
- package/dist/utils/utils.js +2 -3
- package/dist/utils/zod-error.js +2 -3
- package/dist/vector/chunking.js +1 -2
- package/dist/vector/config.js +1 -2
- package/dist/vector/embedding.js +4 -4
- package/package.json +67 -67
- package/src/ai/agents/agent.ts +1 -1
- package/src/api/__tests__/sonamu.plugins.test.ts +11 -1
- package/src/api/__tests__/sonamu.websocket.test.ts +6 -10
- package/src/api/config.ts +1 -1
- package/src/api/context.ts +2 -8
- package/src/api/sonamu.ts +26 -21
- package/src/auth/audit-log/plugin.ts +2 -0
- package/src/compress/types.ts +1 -1
- package/src/exceptions/error-handler.ts +3 -2
- package/src/template/implementations/model.template.ts +3 -3
- package/src/template/implementations/view_list.template.ts +12 -13
- package/src/ui/ai-api.ts +4 -2
- package/src/ui/ai-client.ts +2 -2
- package/src/ui/api.ts +58 -62
- package/dist/ui-web/assets/index-BMdIyKXS.css +0 -1
- package/dist/ui-web/assets/index-LpE8u19O.js +0 -178
|
@@ -111,10 +111,7 @@ describe("Sonamu websocket context scoping", () => {
|
|
|
111
111
|
Reflect.set(Sonamu, "syncerValue", { types: {} });
|
|
112
112
|
|
|
113
113
|
await Sonamu.createWebSocketHandlerForTesting(api, config)(
|
|
114
|
-
{
|
|
115
|
-
socket:
|
|
116
|
-
/* SAFETY: API 데코레이터와 Zod 검증기 등록 계약이 이 값의 타입을 보장한다. */ {} as WebSocket,
|
|
117
|
-
},
|
|
114
|
+
/* SAFETY: API 데코레이터와 Zod 검증기 등록 계약이 이 값의 타입을 보장한다. */ {} as WebSocket,
|
|
118
115
|
request,
|
|
119
116
|
);
|
|
120
117
|
|
|
@@ -369,12 +366,11 @@ describe("Sonamu websocket context scoping", () => {
|
|
|
369
366
|
Reflect.set(Sonamu, "syncerValue", { types: {} });
|
|
370
367
|
|
|
371
368
|
let handlerDone = false;
|
|
372
|
-
const handling = Sonamu.createWebSocketHandlerForTesting(api, config)(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
});
|
|
369
|
+
const handling = Sonamu.createWebSocketHandlerForTesting(api, config)(socket, request).then(
|
|
370
|
+
() => {
|
|
371
|
+
handlerDone = true;
|
|
372
|
+
},
|
|
373
|
+
);
|
|
378
374
|
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
379
375
|
|
|
380
376
|
// 등록이 끝나기 전에는 context를 만들지 않는다
|
package/src/api/config.ts
CHANGED
|
@@ -201,7 +201,7 @@ export type SonamuServerOptions = {
|
|
|
201
201
|
// 프로젝트 외부에서 접근할 수 있는 URL. 기본값은 {server.listen.host}:{server.listen.port} 입니다.
|
|
202
202
|
baseUrl?: string;
|
|
203
203
|
|
|
204
|
-
fastify?: Omit<FastifyServerOptions, "logger">;
|
|
204
|
+
fastify?: Omit<FastifyServerOptions, "logger" | "loggerInstance">;
|
|
205
205
|
|
|
206
206
|
listen?: {
|
|
207
207
|
port: number;
|
package/src/api/context.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IncomingHttpHeaders,
|
|
3
|
-
type IncomingMessage,
|
|
4
|
-
type Server,
|
|
5
|
-
type ServerResponse,
|
|
6
|
-
} from "http";
|
|
1
|
+
import { type IncomingHttpHeaders } from "http";
|
|
7
2
|
|
|
8
3
|
import { type Session, type User } from "better-auth";
|
|
9
4
|
import { type FastifyReply, type FastifyRequest } from "fastify";
|
|
10
|
-
import { type RouteGenericInterface } from "fastify/types/route";
|
|
11
5
|
import { type ZodObject } from "zod";
|
|
12
6
|
|
|
13
7
|
import { type NaiteStore } from "../naite/naite";
|
|
@@ -32,7 +26,7 @@ type BaseContext = {
|
|
|
32
26
|
|
|
33
27
|
export type Context = BaseContext & {
|
|
34
28
|
transport: "http";
|
|
35
|
-
reply: FastifyReply
|
|
29
|
+
reply: FastifyReply;
|
|
36
30
|
createSSE: <T extends ZodObject>(events: T) => ReturnType<typeof createSSEFactory<T>>;
|
|
37
31
|
/** buffer 모드에서 업로드된 파일 */
|
|
38
32
|
bufferedFiles?: BufferedFile[];
|
package/src/api/sonamu.ts
CHANGED
|
@@ -9,7 +9,12 @@ import { dispose as logtapeDispose } from "@logtape/logtape";
|
|
|
9
9
|
import { type Auth, type BetterAuthOptions } from "better-auth";
|
|
10
10
|
import chalk from "chalk";
|
|
11
11
|
import { type FSWatcher } from "chokidar";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
type FastifyBaseLogger,
|
|
14
|
+
type FastifyInstance,
|
|
15
|
+
type FastifyReply,
|
|
16
|
+
type FastifyRequest,
|
|
17
|
+
} from "fastify";
|
|
13
18
|
import mime, { lookup as mimeLookup } from "mime-types";
|
|
14
19
|
import { type WebSocket } from "ws";
|
|
15
20
|
import { type ZodObject } from "zod";
|
|
@@ -470,14 +475,17 @@ class SonamuClass {
|
|
|
470
475
|
const options = this.config.server;
|
|
471
476
|
const { default: fastify } = await import("fastify");
|
|
472
477
|
const { getLogTapeFastifyLogger } = await import("@logtape/fastify");
|
|
478
|
+
// Fastify 5는 logger 옵션에 설정 객체만 받고, 로거 인스턴스는 loggerInstance로 넘겨야 한다
|
|
479
|
+
// SAFETY: LogTape 어댑터는 pino 호환 메서드 집합(trace~fatal, silent, child)을 제공하며 Fastify 4에서도 같은 객체를 logger로 넘겨 동작했다.
|
|
480
|
+
const loggerInstance: FastifyBaseLogger | undefined =
|
|
481
|
+
this.config.logging !== false
|
|
482
|
+
? (getLogTapeFastifyLogger({
|
|
483
|
+
category: this.config.logging?.fastifyCategory ?? ["fastify"],
|
|
484
|
+
}) as FastifyBaseLogger)
|
|
485
|
+
: undefined;
|
|
473
486
|
const server = fastify({
|
|
474
487
|
...options.fastify,
|
|
475
|
-
|
|
476
|
-
this.config.logging !== false
|
|
477
|
-
? getLogTapeFastifyLogger({
|
|
478
|
-
category: this.config.logging?.fastifyCategory ?? ["fastify"],
|
|
479
|
-
})
|
|
480
|
-
: undefined,
|
|
488
|
+
loggerInstance,
|
|
481
489
|
});
|
|
482
490
|
this.server = server;
|
|
483
491
|
this.websocketRuntime = new WebSocketRuntime(options.websocket);
|
|
@@ -714,13 +722,14 @@ class SonamuClass {
|
|
|
714
722
|
// 등록된 API와 일치하지 않는 요청에 대한 fallback입니다.
|
|
715
723
|
throw new NotFoundException(SD("error.api.notFound"));
|
|
716
724
|
},
|
|
717
|
-
wsHandler: async (
|
|
718
|
-
await this.handleDevWebSocketRequest(
|
|
725
|
+
wsHandler: async (socket, request) => {
|
|
726
|
+
await this.handleDevWebSocketRequest(socket, request, config);
|
|
719
727
|
},
|
|
720
728
|
});
|
|
721
729
|
|
|
730
|
+
// HEAD는 위 GET catch-all이 exposeHeadRoutes로 자동 노출하므로 중복 선언하면 Fastify 5가 FST_ERR_DUPLICATED_ROUTE를 던진다
|
|
722
731
|
server.route({
|
|
723
|
-
method: ["
|
|
732
|
+
method: ["POST", "PUT", "DELETE", "PATCH"],
|
|
724
733
|
url: `${this.config.api.route.prefix}/*`,
|
|
725
734
|
handler: async (request, reply) => {
|
|
726
735
|
const handler = await this.handleDevApiRequest(request, config);
|
|
@@ -784,13 +793,14 @@ class SonamuClass {
|
|
|
784
793
|
}
|
|
785
794
|
throw new NotFoundException(SD("error.api.notFound"));
|
|
786
795
|
},
|
|
787
|
-
wsHandler: async (
|
|
788
|
-
await this.handleDevWebSocketRequest(
|
|
796
|
+
wsHandler: async (socket, request) => {
|
|
797
|
+
await this.handleDevWebSocketRequest(socket, request, config);
|
|
789
798
|
},
|
|
790
799
|
});
|
|
791
800
|
|
|
801
|
+
// HEAD는 위 GET catch-all이 exposeHeadRoutes로 자동 노출하므로 중복 선언하면 Fastify 5가 FST_ERR_DUPLICATED_ROUTE를 던진다
|
|
792
802
|
server.route({
|
|
793
|
-
method: ["
|
|
803
|
+
method: ["POST", "PUT", "DELETE", "PATCH"],
|
|
794
804
|
url: `${this.config.api.route.prefix}/*`,
|
|
795
805
|
handler: async (request, reply) => {
|
|
796
806
|
const result = await this.handleDevApiRequest(request, config);
|
|
@@ -1380,7 +1390,7 @@ class SonamuClass {
|
|
|
1380
1390
|
}
|
|
1381
1391
|
|
|
1382
1392
|
const handler = this.createWebSocketHandler(matchedApi, config);
|
|
1383
|
-
await handler(
|
|
1393
|
+
await handler(socket, request);
|
|
1384
1394
|
}
|
|
1385
1395
|
|
|
1386
1396
|
// WS route 핸들러의 실행 순서를 고정함:
|
|
@@ -1393,13 +1403,8 @@ class SonamuClass {
|
|
|
1393
1403
|
}
|
|
1394
1404
|
|
|
1395
1405
|
private createWebSocketHandler(api: ExtendedApi, config: SonamuFastifyConfig) {
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
socket: WebSocket;
|
|
1399
|
-
},
|
|
1400
|
-
request: FastifyRequest,
|
|
1401
|
-
): Promise<void> => {
|
|
1402
|
-
const socket = connection.socket;
|
|
1406
|
+
// @fastify/websocket 11부터 wsHandler는 connection 래퍼 대신 ws.WebSocket을 직접 전달한다
|
|
1407
|
+
return async (socket: WebSocket, request: FastifyRequest): Promise<void> => {
|
|
1403
1408
|
let wsContext: WebSocketContext<object, object> | null = null;
|
|
1404
1409
|
let rawWs: Awaited<ReturnType<WebSocketRuntime["registerConnection"]>> | null = null;
|
|
1405
1410
|
let preRegisterPhase: "guard" | "query" | "register" | "handler" = "guard";
|
|
@@ -85,6 +85,8 @@ const getOrganizationTriggerInfo = (user: { id?: string } | null | undefined): B
|
|
|
85
85
|
type BetterAuthRequestCtx = GenericEndpointContext & {
|
|
86
86
|
context: GenericEndpointContext["context"] & {
|
|
87
87
|
location?: BuilderLocation | null;
|
|
88
|
+
// after hook에서 dispatch가 채우는 응답값. better-auth 1.6.2x부터 GenericEndpointContext 타입에서 빠졌지만 HookEndpointContext에는 남아 있다.
|
|
89
|
+
returned?: unknown;
|
|
88
90
|
};
|
|
89
91
|
};
|
|
90
92
|
|
package/src/compress/types.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type CompressOptions = {
|
|
|
14
14
|
/** 압축을 적용할 최소 바이트 크기 (기본값: 1024) */
|
|
15
15
|
threshold?: number;
|
|
16
16
|
/** 사용할 인코딩 우선순위 (기본값: ["br", "gzip", "deflate"]) */
|
|
17
|
-
encodings?: ("br" | "gzip" | "deflate" | "identity")[];
|
|
17
|
+
encodings?: ("zstd" | "br" | "gzip" | "deflate" | "identity")[];
|
|
18
18
|
/** 압축할 Content-Type 필터 */
|
|
19
19
|
customTypes?: RegExp | ((contentType: string) => boolean);
|
|
20
20
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FastifyInstance } from "fastify";
|
|
1
|
+
import { type FastifyError, type FastifyInstance } from "fastify";
|
|
2
2
|
import type z from "zod";
|
|
3
3
|
|
|
4
4
|
import { isObjectValue, isStringValue } from "../utils/runtime-value";
|
|
@@ -19,7 +19,8 @@ function isZodIssuePayload<Value>(payload: Value): payload is Value & z.core.$Zo
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function setupErrorHandler(server: FastifyInstance) {
|
|
22
|
-
|
|
22
|
+
// Fastify 5는 error 타입 기본값이 unknown이므로 기존 FastifyError 계약을 명시한다
|
|
23
|
+
server.setErrorHandler<FastifyError>((error, request, reply) => {
|
|
23
24
|
error.statusCode ??= 400;
|
|
24
25
|
|
|
25
26
|
if (isSoException(error) && isZodIssuePayload(error.payload)) {
|
|
@@ -33,9 +33,9 @@ export class Template__model extends Template {
|
|
|
33
33
|
const listParamsNode = zodTypeToRenderingNode(listParamsZodType);
|
|
34
34
|
|
|
35
35
|
const subsetKeyZodType = await getZodTypeById(`${entityId}SubsetKey`);
|
|
36
|
-
const subsetKeys =
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const subsetKeys = /* SAFETY: 생성된 *SubsetKey 타입은 enum 스키마로 등록된다. */ (
|
|
37
|
+
subsetKeyZodType as z.ZodEnum
|
|
38
|
+
).enum;
|
|
39
39
|
|
|
40
40
|
const names = EntityManager.getNamesFromId(entityId);
|
|
41
41
|
const entity = EntityManager.get(entityId);
|
|
@@ -305,20 +305,19 @@ export class Template__view_list extends Template {
|
|
|
305
305
|
});
|
|
306
306
|
|
|
307
307
|
// 필터 컬럼
|
|
308
|
-
const filterColumns =
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
const filterColumns = /* SAFETY: ListParams 렌더링 노드의 자식은 모두 필터 컬럼 노드다. */ (
|
|
309
|
+
listParamsNode.children as RenderingNode[]
|
|
310
|
+
)
|
|
311
|
+
.filter(
|
|
312
|
+
(col) =>
|
|
313
|
+
col.name !== "id" &&
|
|
314
|
+
col.name !== "queryMode" &&
|
|
315
|
+
["enums", "number-id", "number-fk_id", "string-fk_id"].includes(col.renderType),
|
|
311
316
|
)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
["enums", "number-id", "number-fk_id", "string-fk_id"].includes(col.renderType),
|
|
317
|
-
)
|
|
318
|
-
// orderBy가 가장 뒤로 오게 순서 조정
|
|
319
|
-
.toSorted((a) => {
|
|
320
|
-
return a.name === "orderBy" ? 1 : -1;
|
|
321
|
-
});
|
|
317
|
+
// orderBy가 가장 뒤로 오게 순서 조정
|
|
318
|
+
.toSorted((a) => {
|
|
319
|
+
return a.name === "orderBy" ? 1 : -1;
|
|
320
|
+
});
|
|
322
321
|
|
|
323
322
|
// 필터 컬럼을 프리 템플릿으로 설정
|
|
324
323
|
const preTemplates: RenderedTemplate["preTemplates"] = [];
|
package/src/ui/ai-api.ts
CHANGED
|
@@ -24,7 +24,8 @@ export async function setAiApi(server: FastifyInstance) {
|
|
|
24
24
|
const result = aiClient.handleFixture(await convertToModelMessages(messages), fixtureRecords);
|
|
25
25
|
const response = result.toUIMessageStreamResponse();
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// ai 7의 Response.headers는 Headers 인스턴스라 entries()로 풀어야 Node 응답 헤더로 전달된다
|
|
28
|
+
reply.raw.writeHead(response.status, Object.fromEntries(response.headers.entries()));
|
|
28
29
|
|
|
29
30
|
if (response.body) {
|
|
30
31
|
const reader = response.body.getReader();
|
|
@@ -49,7 +50,8 @@ export async function setAiApi(server: FastifyInstance) {
|
|
|
49
50
|
const result = aiClient.handleEntity(await convertToModelMessages(messages));
|
|
50
51
|
const response = result.toUIMessageStreamResponse();
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
// ai 7의 Response.headers는 Headers 인스턴스라 entries()로 풀어야 Node 응답 헤더로 전달된다
|
|
54
|
+
reply.raw.writeHead(response.status, Object.fromEntries(response.headers.entries()));
|
|
53
55
|
|
|
54
56
|
if (response.body) {
|
|
55
57
|
const reader = response.body.getReader();
|
package/src/ui/ai-client.ts
CHANGED
|
@@ -52,7 +52,7 @@ class AIClient {
|
|
|
52
52
|
handleFixture(
|
|
53
53
|
messages: ModelMessage[],
|
|
54
54
|
fixtureRecords: FixtureRecord[],
|
|
55
|
-
): StreamTextResult<any, any> {
|
|
55
|
+
): StreamTextResult<any, any, any> {
|
|
56
56
|
if (!this.aiSdk || !this.model) {
|
|
57
57
|
throw new Error("AI SDK not initialized. Call init() first.");
|
|
58
58
|
}
|
|
@@ -253,7 +253,7 @@ class AIClient {
|
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
handleEntity(messages: ModelMessage[]): StreamTextResult<any, any> {
|
|
256
|
+
handleEntity(messages: ModelMessage[]): StreamTextResult<any, any, any> {
|
|
257
257
|
if (!this.aiSdk || !this.model) {
|
|
258
258
|
throw new Error("AI SDK not initialized. Call init() first.");
|
|
259
259
|
}
|
package/src/ui/api.ts
CHANGED
|
@@ -323,54 +323,52 @@ export async function sonamuUIApiPlugin(fastify: FastifyInstance) {
|
|
|
323
323
|
filter?: "enums" | "types";
|
|
324
324
|
reload?: "1";
|
|
325
325
|
};
|
|
326
|
-
}>(
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
forwardAsyncErrors(async () => {
|
|
330
|
-
const { filter, reload } = request.query;
|
|
331
|
-
|
|
332
|
-
if (reload === "1") {
|
|
333
|
-
await Sonamu.syncer.autoloadTypes();
|
|
334
|
-
}
|
|
326
|
+
}>("/api/entity/typeIds", (request): Promise<{ typeIds: string[] }> =>
|
|
327
|
+
forwardAsyncErrors(async () => {
|
|
328
|
+
const { filter, reload } = request.query;
|
|
335
329
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
.filter(([_typeId, zodType]) => {
|
|
340
|
-
const { _zod: zodMetadata } = zodType;
|
|
341
|
-
return (
|
|
342
|
-
/* SAFETY: UI 도구의 Zod 입력 스키마가 이 값의 타입을 보장한다. */ (zodMetadata
|
|
343
|
-
.def.type as string) !== "enum"
|
|
344
|
-
);
|
|
345
|
-
})
|
|
346
|
-
.map(([typeId, _zodType]) => typeId);
|
|
347
|
-
|
|
348
|
-
// 내장 타입들 (sonamu 코어에서 제공)
|
|
349
|
-
const builtInTypeIds = [...BUILT_IN_TYPE_IDS];
|
|
350
|
-
|
|
351
|
-
// 모든 타입 병합
|
|
352
|
-
const allTypeIds = [...builtInTypeIds, ...projectTypeIds];
|
|
353
|
-
|
|
354
|
-
if (filter === "types") {
|
|
355
|
-
return allTypeIds;
|
|
356
|
-
}
|
|
330
|
+
if (reload === "1") {
|
|
331
|
+
await Sonamu.syncer.autoloadTypes();
|
|
332
|
+
}
|
|
357
333
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
334
|
+
const typeIds = (() => {
|
|
335
|
+
// 프로젝트에서 정의한 타입들
|
|
336
|
+
const projectTypeIds = Object.entries(Sonamu.syncer.types)
|
|
337
|
+
.filter(([_typeId, zodType]) => {
|
|
338
|
+
const { _zod: zodMetadata } = zodType;
|
|
339
|
+
return (
|
|
340
|
+
/* SAFETY: UI 도구의 Zod 입력 스키마가 이 값의 타입을 보장한다. */ (zodMetadata
|
|
341
|
+
.def.type as string) !== "enum"
|
|
342
|
+
);
|
|
343
|
+
})
|
|
344
|
+
.map(([typeId, _zodType]) => typeId);
|
|
362
345
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
} else {
|
|
366
|
-
return [...allTypeIds, ...enumIds];
|
|
367
|
-
}
|
|
368
|
-
})();
|
|
346
|
+
// 내장 타입들 (sonamu 코어에서 제공)
|
|
347
|
+
const builtInTypeIds = [...BUILT_IN_TYPE_IDS];
|
|
369
348
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
349
|
+
// 모든 타입 병합
|
|
350
|
+
const allTypeIds = [...builtInTypeIds, ...projectTypeIds];
|
|
351
|
+
|
|
352
|
+
if (filter === "types") {
|
|
353
|
+
return allTypeIds;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const enumIds = EntityManager.getAllIds().flatMap((entityId) => {
|
|
357
|
+
const entity = EntityManager.get(entityId);
|
|
358
|
+
return Object.keys(entity.enumLabels);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
if (filter === "enums") {
|
|
362
|
+
return enumIds;
|
|
363
|
+
} else {
|
|
364
|
+
return [...allTypeIds, ...enumIds];
|
|
365
|
+
}
|
|
366
|
+
})();
|
|
367
|
+
|
|
368
|
+
return {
|
|
369
|
+
typeIds,
|
|
370
|
+
};
|
|
371
|
+
}),
|
|
374
372
|
);
|
|
375
373
|
|
|
376
374
|
server.post<{
|
|
@@ -902,25 +900,23 @@ export async function sonamuUIApiPlugin(fastify: FastifyInstance) {
|
|
|
902
900
|
enumId?: string;
|
|
903
901
|
};
|
|
904
902
|
};
|
|
905
|
-
}>(
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
forwardAsyncErrors(async () => {
|
|
909
|
-
const { option } = request.body;
|
|
910
|
-
|
|
911
|
-
try {
|
|
912
|
-
const { templateKey, ...templateOptions } = option;
|
|
913
|
-
const pathAndCodes = await Sonamu.syncer.renderTemplate(
|
|
914
|
-
/* SAFETY: UI 도구의 Zod 입력 스키마가 이 값의 타입을 보장한다. */ templateKey as TemplateKey,
|
|
915
|
-
templateOptions,
|
|
916
|
-
);
|
|
903
|
+
}>("/api/scaffolding/preview", (request): Promise<{ pathAndCodes: PathAndCode[] }> =>
|
|
904
|
+
forwardAsyncErrors(async () => {
|
|
905
|
+
const { option } = request.body;
|
|
917
906
|
|
|
918
|
-
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
907
|
+
try {
|
|
908
|
+
const { templateKey, ...templateOptions } = option;
|
|
909
|
+
const pathAndCodes = await Sonamu.syncer.renderTemplate(
|
|
910
|
+
/* SAFETY: UI 도구의 Zod 입력 스키마가 이 값의 타입을 보장한다. */ templateKey as TemplateKey,
|
|
911
|
+
templateOptions,
|
|
912
|
+
);
|
|
913
|
+
|
|
914
|
+
return { pathAndCodes };
|
|
915
|
+
} catch (e) {
|
|
916
|
+
console.error(e);
|
|
917
|
+
throw e;
|
|
918
|
+
}
|
|
919
|
+
}),
|
|
924
920
|
);
|
|
925
921
|
|
|
926
922
|
server.post("/api/fixture", (request) =>
|