sonamu 0.7.53 → 0.8.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.
- package/dist/api/config.d.ts +9 -1
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +1 -1
- package/dist/api/sonamu.d.ts +21 -1
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +159 -65
- package/dist/auth/plugins/entity-definitions/anonymous.d.ts +10 -0
- package/dist/auth/plugins/entity-definitions/anonymous.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/anonymous.js +23 -0
- package/dist/auth/plugins/entity-definitions/api-key.d.ts +9 -0
- package/dist/auth/plugins/entity-definitions/api-key.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/api-key.js +199 -0
- package/dist/auth/plugins/entity-definitions/index.d.ts +6 -0
- package/dist/auth/plugins/entity-definitions/index.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/index.js +20 -2
- package/dist/auth/plugins/entity-definitions/jwt.d.ts +9 -0
- package/dist/auth/plugins/entity-definitions/jwt.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/jwt.js +67 -0
- package/dist/auth/plugins/entity-definitions/organization.d.ts +9 -0
- package/dist/auth/plugins/entity-definitions/organization.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/organization.js +424 -0
- package/dist/auth/plugins/entity-definitions/passkey.d.ts +10 -0
- package/dist/auth/plugins/entity-definitions/passkey.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/passkey.js +129 -0
- package/dist/auth/plugins/entity-definitions/sso.d.ts +10 -0
- package/dist/auth/plugins/entity-definitions/sso.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/sso.js +110 -0
- package/dist/auth/plugins/entity-definitions/types.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/types.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/types.js +1 -1
- package/dist/auth/plugins/wrappers/admin.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/admin.js +2 -4
- package/dist/auth/plugins/wrappers/anonymous.d.ts +18 -0
- package/dist/auth/plugins/wrappers/anonymous.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/anonymous.js +26 -0
- package/dist/auth/plugins/wrappers/api-key.d.ts +18 -0
- package/dist/auth/plugins/wrappers/api-key.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/api-key.js +38 -0
- package/dist/auth/plugins/wrappers/index.d.ts +6 -0
- package/dist/auth/plugins/wrappers/index.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/index.js +7 -1
- package/dist/auth/plugins/wrappers/jwt.d.ts +18 -0
- package/dist/auth/plugins/wrappers/jwt.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/jwt.js +30 -0
- package/dist/auth/plugins/wrappers/organization.d.ts +18 -0
- package/dist/auth/plugins/wrappers/organization.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/organization.js +67 -0
- package/dist/auth/plugins/wrappers/passkey.d.ts +18 -0
- package/dist/auth/plugins/wrappers/passkey.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/passkey.js +32 -0
- package/dist/auth/plugins/wrappers/phone-number.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/phone-number.js +2 -4
- package/dist/auth/plugins/wrappers/sso.d.ts +853 -0
- package/dist/auth/plugins/wrappers/sso.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/sso.js +36 -0
- package/dist/auth/plugins/wrappers/two-factor.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/two-factor.js +2 -4
- package/dist/auth/plugins/wrappers/username.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/username.js +2 -4
- package/dist/bin/build-config.d.ts +2 -2
- package/dist/bin/build-config.js +6 -7
- package/dist/bin/cli.js +417 -32
- package/dist/bin/fixture.d.ts +27 -0
- package/dist/bin/fixture.d.ts.map +1 -0
- package/dist/bin/fixture.js +245 -0
- package/dist/cache/decorator.d.ts +4 -3
- package/dist/cache/decorator.d.ts.map +1 -1
- package/dist/cache/decorator.js +5 -4
- package/dist/cone/cone-generator.d.ts +33 -0
- package/dist/cone/cone-generator.d.ts.map +1 -0
- package/dist/cone/cone-generator.js +286 -0
- package/dist/database/_batch_update.d.ts.map +1 -1
- package/dist/database/_batch_update.js +16 -2
- package/dist/database/puri-subset.test-d.js +1 -1
- package/dist/database/puri-subset.types.d.ts +1 -1
- package/dist/database/puri-subset.types.d.ts.map +1 -1
- package/dist/database/puri-subset.types.js +1 -1
- package/dist/database/puri.d.ts +4 -0
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +20 -2
- package/dist/database/upsert-builder.d.ts.map +1 -1
- package/dist/database/upsert-builder.js +19 -3
- package/dist/dict/en.d.ts +15 -0
- package/dist/dict/en.d.ts.map +1 -1
- package/dist/dict/en.js +2 -1
- package/dist/dict/ko.d.ts +15 -0
- package/dist/dict/ko.d.ts.map +1 -1
- package/dist/dict/ko.js +2 -1
- package/dist/dict/rc-keys.d.ts +28 -0
- package/dist/dict/rc-keys.d.ts.map +1 -1
- package/dist/dict/rc-keys.js +31 -1
- package/dist/dict/sd.d.ts.map +1 -1
- package/dist/dict/sd.js +20 -4
- package/dist/entity/entity-manager.d.ts +298 -2
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +4 -1
- package/dist/entity/entity-template-cone.d.ts +14 -0
- package/dist/entity/entity-template-cone.d.ts.map +1 -0
- package/dist/entity/entity-template-cone.js +222 -0
- package/dist/entity/entity.d.ts +47 -2
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +161 -14
- package/dist/ssr/renderer.js +3 -3
- package/dist/syncer/api-parser.js +12 -1
- package/dist/syncer/checksum.d.ts +0 -14
- package/dist/syncer/checksum.d.ts.map +1 -1
- package/dist/syncer/checksum.js +1 -23
- package/dist/syncer/syncer-actions.d.ts.map +1 -1
- package/dist/syncer/syncer-actions.js +8 -2
- package/dist/syncer/syncer.d.ts +1 -1
- package/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js +17 -10
- package/dist/tasks/workflow-manager.d.ts +13 -1
- package/dist/tasks/workflow-manager.d.ts.map +1 -1
- package/dist/tasks/workflow-manager.js +18 -1
- package/dist/template/entity-converter.js +4 -4
- package/dist/template/helpers.d.ts +10 -0
- package/dist/template/helpers.d.ts.map +1 -1
- package/dist/template/helpers.js +48 -1
- package/dist/template/implementations/entry-server.template.d.ts +1 -1
- package/dist/template/implementations/entry-server.template.js +7 -2
- package/dist/template/implementations/generated.template.d.ts.map +1 -1
- package/dist/template/implementations/generated.template.js +5 -1
- package/dist/template/implementations/generated_http.template.d.ts +1 -0
- package/dist/template/implementations/generated_http.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_http.template.js +6 -2
- package/dist/template/implementations/generated_sso.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_sso.template.js +29 -8
- package/dist/template/implementations/queries.template.d.ts.map +1 -1
- package/dist/template/implementations/queries.template.js +9 -1
- package/dist/template/implementations/sd.template.d.ts +1 -1
- package/dist/template/implementations/sd.template.d.ts.map +1 -1
- package/dist/template/implementations/sd.template.js +28 -4
- package/dist/template/implementations/services.template.d.ts.map +1 -1
- package/dist/template/implementations/services.template.js +12 -12
- package/dist/template/implementations/view_form.template.d.ts +11 -7
- package/dist/template/implementations/view_form.template.d.ts.map +1 -1
- package/dist/template/implementations/view_form.template.js +97 -87
- package/dist/template/implementations/view_list.template.d.ts +3 -3
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +115 -109
- package/dist/template/implementations/view_search_input.template.d.ts.map +1 -1
- package/dist/template/implementations/view_search_input.template.js +18 -14
- package/dist/template/zod-converter.d.ts.map +1 -1
- package/dist/template/zod-converter.js +95 -7
- package/dist/testing/_relation-graph.js +1 -1
- package/dist/testing/data-explorer.d.ts +61 -0
- package/dist/testing/data-explorer.d.ts.map +1 -0
- package/dist/testing/data-explorer.js +274 -0
- package/dist/testing/faker-mappings.d.ts +20 -0
- package/dist/testing/faker-mappings.d.ts.map +1 -0
- package/dist/testing/faker-mappings.js +421 -0
- package/dist/testing/fixture-generator.d.ts +161 -0
- package/dist/testing/fixture-generator.d.ts.map +1 -0
- package/dist/testing/fixture-generator.js +954 -0
- package/dist/testing/fixture-manager.d.ts +6 -1
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +72 -4
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +4 -1
- package/dist/types/types.d.ts +1520 -26
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +136 -22
- package/dist/ui/ai-client.d.ts.map +1 -1
- package/dist/ui/ai-client.js +9 -4
- package/dist/ui/api.d.ts.map +1 -1
- package/dist/ui/api.js +303 -24
- package/dist/ui-web/assets/index-CsUr-_pV.js +254 -0
- package/dist/ui-web/assets/index-T42zzs1K.css +1 -0
- package/dist/ui-web/index.html +2 -2
- package/dist/utils/fs-utils.d.ts +2 -1
- package/dist/utils/fs-utils.d.ts.map +1 -1
- package/dist/utils/fs-utils.js +14 -3
- package/package.json +19 -11
- package/src/api/config.ts +12 -1
- package/src/api/sonamu.ts +179 -65
- package/src/auth/plugins/entity-definitions/anonymous.ts +17 -0
- package/src/auth/plugins/entity-definitions/api-key.ts +93 -0
- package/src/auth/plugins/entity-definitions/index.ts +18 -0
- package/src/auth/plugins/entity-definitions/jwt.ts +35 -0
- package/src/auth/plugins/entity-definitions/organization.ts +215 -0
- package/src/auth/plugins/entity-definitions/passkey.ts +64 -0
- package/src/auth/plugins/entity-definitions/sso.ts +62 -0
- package/src/auth/plugins/entity-definitions/types.ts +11 -1
- package/src/auth/plugins/wrappers/admin.ts +1 -3
- package/src/auth/plugins/wrappers/anonymous.ts +30 -0
- package/src/auth/plugins/wrappers/api-key.ts +42 -0
- package/src/auth/plugins/wrappers/index.ts +6 -0
- package/src/auth/plugins/wrappers/jwt.ts +34 -0
- package/src/auth/plugins/wrappers/organization.ts +73 -0
- package/src/auth/plugins/wrappers/passkey.ts +36 -0
- package/src/auth/plugins/wrappers/phone-number.ts +1 -3
- package/src/auth/plugins/wrappers/sso.ts +40 -0
- package/src/auth/plugins/wrappers/two-factor.ts +1 -3
- package/src/auth/plugins/wrappers/username.ts +1 -3
- package/src/bin/build-config.ts +6 -6
- package/src/bin/cli.ts +452 -31
- package/src/bin/fixture.ts +302 -0
- package/src/cache/decorator.ts +4 -3
- package/src/cone/cone-generator.ts +363 -0
- package/src/database/_batch_update.ts +11 -0
- package/src/database/puri-subset.test-d.ts +13 -13
- package/src/database/puri-subset.types.ts +1 -1
- package/src/database/puri.ts +43 -1
- package/src/database/upsert-builder.ts +16 -2
- package/src/dict/en.ts +1 -0
- package/src/dict/ko.ts +1 -0
- package/src/dict/rc-keys.ts +32 -0
- package/src/dict/sd.ts +23 -3
- package/src/entity/entity-manager.ts +4 -0
- package/src/entity/entity-template-cone.ts +298 -0
- package/src/entity/entity.ts +189 -13
- package/src/shared/app.shared.ts.txt +5 -0
- package/src/shared/web.shared.ts.txt +9 -5
- package/src/skills/project/README.md +21 -0
- package/src/skills/project/architecture.md +373 -0
- package/src/skills/project/business-logic.md +270 -0
- package/src/skills/project/requirements.md +160 -0
- package/src/skills/sonamu/SKILL.md +168 -3
- package/src/skills/sonamu/api.md +102 -0
- package/src/skills/sonamu/database.md +220 -1
- package/src/skills/sonamu/entity-relations.md +89 -1
- package/src/skills/sonamu/fixture-cli.md +501 -0
- package/src/skills/sonamu/frontend.md +214 -0
- package/src/skills/sonamu/i18n.md +95 -0
- package/src/skills/sonamu/model.md +153 -0
- package/src/skills/sonamu/project-init.md +178 -8
- package/src/skills/sonamu/scaffolding.md +112 -0
- package/src/skills/sonamu/subset.md +9 -3
- package/src/skills/sonamu/testing.md +287 -2
- package/src/skills/sonamu/workflow.md +70 -5
- package/src/ssr/renderer.ts +2 -2
- package/src/syncer/api-parser.ts +12 -0
- package/src/syncer/checksum.ts +0 -38
- package/src/syncer/syncer-actions.ts +7 -1
- package/src/syncer/syncer.ts +16 -5
- package/src/tasks/workflow-manager.ts +29 -8
- package/src/template/entity-converter.ts +3 -3
- package/src/template/helpers.ts +49 -0
- package/src/template/implementations/entry-server.template.ts +1 -1
- package/src/template/implementations/generated.template.ts +4 -0
- package/src/template/implementations/generated_http.template.ts +1 -0
- package/src/template/implementations/generated_sso.template.ts +40 -11
- package/src/template/implementations/queries.template.ts +8 -0
- package/src/template/implementations/sd.template.ts +22 -3
- package/src/template/implementations/services.template.ts +11 -10
- package/src/template/implementations/view_form.template.ts +111 -101
- package/src/template/implementations/view_list.template.ts +120 -119
- package/src/template/implementations/view_search_input.template.ts +17 -13
- package/src/template/zod-converter.ts +103 -6
- package/src/testing/_relation-graph.ts +1 -1
- package/src/testing/data-explorer.ts +427 -0
- package/src/testing/faker-mappings.ts +434 -0
- package/src/testing/fixture-generator.ts +1166 -0
- package/src/testing/fixture-manager.ts +91 -6
- package/src/testing/index.ts +3 -0
- package/src/types/types.ts +222 -26
- package/src/ui/ai-client.ts +9 -1
- package/src/ui/api.ts +429 -23
- package/src/utils/fs-utils.ts +14 -1
- package/dist/template/implementations/view_enums_select.template.d.ts +0 -17
- package/dist/template/implementations/view_enums_select.template.d.ts.map +0 -1
- package/dist/template/implementations/view_enums_select.template.js +0 -62
- package/dist/template/implementations/view_id_async_select.template.d.ts +0 -17
- package/dist/template/implementations/view_id_async_select.template.d.ts.map +0 -1
- package/dist/template/implementations/view_id_async_select.template.js +0 -125
- package/dist/ui-web/assets/index-Bd_2AkLb.css +0 -1
- package/dist/ui-web/assets/index-BpSbhQWo.js +0 -225
- package/src/template/implementations/view_enums_select.template.ts +0 -65
- package/src/template/implementations/view_id_async_select.template.ts +0 -139
package/src/ui/api.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { execSync } from "child_process";
|
|
|
2
2
|
import type { FastifyInstance } from "fastify";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import inflection from "inflection";
|
|
5
|
+
import type { AddressInfo } from "net";
|
|
5
6
|
import path from "path";
|
|
6
7
|
import { range } from "radashi";
|
|
7
8
|
import { Sonamu } from "../api/sonamu";
|
|
8
|
-
import type
|
|
9
|
+
import { DB, type SonamuDBConfig } from "../database/db";
|
|
10
|
+
import { createKnexInstance } from "../database/knex";
|
|
9
11
|
import { SD } from "../dict/sd";
|
|
10
12
|
import { sonamuDictionary } from "../dict/sonamu-dictionary";
|
|
11
13
|
import type { Entity } from "../entity/entity";
|
|
@@ -18,9 +20,12 @@ import {
|
|
|
18
20
|
import { type MigrationResult, Migrator } from "../migration/migrator";
|
|
19
21
|
import { SlackConfirm, type SlackConfirmPendingResult } from "../migration/slack-confirm";
|
|
20
22
|
import { TemplateManager } from "../template/template-manager";
|
|
23
|
+
import { DataExplorer } from "../testing/data-explorer";
|
|
24
|
+
import { FixtureGenerator } from "../testing/fixture-generator";
|
|
21
25
|
import { type DuplicateCheckOptions, FixtureManager } from "../testing/fixture-manager";
|
|
22
26
|
import {
|
|
23
27
|
BUILT_IN_TYPE_IDS,
|
|
28
|
+
type Cone,
|
|
24
29
|
type EntityIndex,
|
|
25
30
|
type EntityProp,
|
|
26
31
|
type EntitySubsetRow,
|
|
@@ -583,6 +588,105 @@ export async function sonamuUIApiPlugin(fastify: FastifyInstance) {
|
|
|
583
588
|
});
|
|
584
589
|
});
|
|
585
590
|
|
|
591
|
+
server.post<{
|
|
592
|
+
Body: {
|
|
593
|
+
entityId: string;
|
|
594
|
+
target: "entity" | "prop" | "enum" | "subset";
|
|
595
|
+
propName?: string;
|
|
596
|
+
enumId?: string;
|
|
597
|
+
subsetKey?: string;
|
|
598
|
+
cone: Cone;
|
|
599
|
+
};
|
|
600
|
+
}>("/api/entity/updateCone", async (request) => {
|
|
601
|
+
return await waitForHMRCompleted(async () => {
|
|
602
|
+
const { entityId, target, propName, enumId, subsetKey, cone } = request.body;
|
|
603
|
+
const entity = EntityManager.get(entityId);
|
|
604
|
+
|
|
605
|
+
if (target === "entity") {
|
|
606
|
+
entity.cone = cone;
|
|
607
|
+
} else if (target === "prop" && propName) {
|
|
608
|
+
const prop = entity.props.find((p) => p.name === propName);
|
|
609
|
+
if (prop) {
|
|
610
|
+
(prop as { cone?: Cone }).cone = cone;
|
|
611
|
+
}
|
|
612
|
+
} else if (target === "enum" && enumId) {
|
|
613
|
+
entity.enumCones[enumId] = cone;
|
|
614
|
+
} else if (target === "subset" && subsetKey) {
|
|
615
|
+
entity.subsetCones[subsetKey] = cone;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
await entity.save();
|
|
619
|
+
return true;
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
server.post<{
|
|
624
|
+
Body: {
|
|
625
|
+
entityId: string;
|
|
626
|
+
preserveExisting?: boolean;
|
|
627
|
+
onlyEmpty?: boolean;
|
|
628
|
+
locale?: "ko" | "en" | "ja";
|
|
629
|
+
};
|
|
630
|
+
}>("/api/entity/generateCones", async (request, reply) => {
|
|
631
|
+
return await waitForHMRCompleted(async () => {
|
|
632
|
+
const { entityId, preserveExisting, onlyEmpty, locale } = request.body;
|
|
633
|
+
|
|
634
|
+
try {
|
|
635
|
+
// Entity 존재 여부 확인
|
|
636
|
+
const entity = EntityManager.get(entityId);
|
|
637
|
+
|
|
638
|
+
// locale 기본값: Sonamu.config.i18n.defaultLocale 사용
|
|
639
|
+
const effectiveLocale =
|
|
640
|
+
locale ?? (Sonamu.config.i18n.defaultLocale as "ko" | "en" | "ja");
|
|
641
|
+
|
|
642
|
+
// Cone 생성
|
|
643
|
+
const result = await entity.generateCones({
|
|
644
|
+
preserveExisting: preserveExisting ?? true,
|
|
645
|
+
onlyEmpty: onlyEmpty ?? false,
|
|
646
|
+
locale: effectiveLocale,
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
return result;
|
|
650
|
+
} catch (error: unknown) {
|
|
651
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
652
|
+
|
|
653
|
+
// Entity not found
|
|
654
|
+
if (message.includes("존재하지 않는 Entity")) {
|
|
655
|
+
reply.status(404);
|
|
656
|
+
return {
|
|
657
|
+
success: false,
|
|
658
|
+
error: `Entity not found: ${entityId}`,
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// API 키 없음
|
|
663
|
+
if (message.includes("ANTHROPIC_API_KEY not found")) {
|
|
664
|
+
reply.status(500);
|
|
665
|
+
return {
|
|
666
|
+
success: false,
|
|
667
|
+
error: "API key not configured",
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// Rate limit
|
|
672
|
+
if (message.includes("Rate limit exceeded")) {
|
|
673
|
+
reply.status(429);
|
|
674
|
+
return {
|
|
675
|
+
success: false,
|
|
676
|
+
error: "Rate limit exceeded. Please try again later.",
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// 기타 에러
|
|
681
|
+
reply.status(500);
|
|
682
|
+
return {
|
|
683
|
+
success: false,
|
|
684
|
+
error: `Cone generation failed: ${message}`,
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
|
|
586
690
|
server.get<{
|
|
587
691
|
Querystring: {
|
|
588
692
|
entityId: string;
|
|
@@ -766,19 +870,15 @@ export async function sonamuUIApiPlugin(fastify: FastifyInstance) {
|
|
|
766
870
|
|
|
767
871
|
server.post<{
|
|
768
872
|
Body: {
|
|
769
|
-
templateGroupName: "Entity" | "Enums";
|
|
770
873
|
entityIds: string[];
|
|
771
874
|
templateKeys: string[];
|
|
772
|
-
enumIds: string[];
|
|
773
875
|
};
|
|
774
876
|
}>("/api/scaffolding/getStatus", async (request) => {
|
|
775
|
-
const {
|
|
877
|
+
const { entityIds, templateKeys: _templateKeys } = request.body;
|
|
776
878
|
if ((entityIds ?? []).length === 0) {
|
|
777
879
|
throw new BadRequestException(SD("sonamu.error.entityIdsRequired"));
|
|
778
880
|
} else if ((_templateKeys ?? []).length === 0) {
|
|
779
881
|
throw new BadRequestException(SD("sonamu.error.templateKeysRequired"));
|
|
780
|
-
} else if (templateGroupName === "Enums" && (enumIds ?? []).length === 0) {
|
|
781
|
-
throw new BadRequestException(SD("sonamu.error.enumIdsRequired"));
|
|
782
882
|
}
|
|
783
883
|
|
|
784
884
|
// sorting
|
|
@@ -786,33 +886,18 @@ export async function sonamuUIApiPlugin(fastify: FastifyInstance) {
|
|
|
786
886
|
const templateKeys = TemplateKey.options.filter((tk) => _templateKeys.includes(tk));
|
|
787
887
|
|
|
788
888
|
const combinations = entityIds.flatMap((entityId) => {
|
|
789
|
-
|
|
790
|
-
const entityIds = [entityId, ...EntityManager.getChildrenIds(entityId)];
|
|
791
|
-
const allEnumIds = entityIds.flatMap((entityId) =>
|
|
792
|
-
Object.keys(EntityManager.get(entityId).enumLabels),
|
|
793
|
-
);
|
|
794
|
-
return templateKeys.flatMap((templateKey) =>
|
|
795
|
-
allEnumIds
|
|
796
|
-
.filter((enumId) => enumIds.includes(enumId))
|
|
797
|
-
.map((enumId) => [entityId, templateKey, enumId]),
|
|
798
|
-
);
|
|
799
|
-
} else {
|
|
800
|
-
return templateKeys.map((templateKey) => [entityId, templateKey]);
|
|
801
|
-
}
|
|
889
|
+
return templateKeys.map((templateKey) => [entityId, templateKey]);
|
|
802
890
|
});
|
|
803
891
|
|
|
804
892
|
const statuses = await Promise.all(
|
|
805
|
-
combinations.map(async ([entityId, templateKey
|
|
893
|
+
combinations.map(async ([entityId, templateKey]) => {
|
|
806
894
|
const { subPath, fullPath, isExists } = await Sonamu.syncer.checkExistsGenCode(
|
|
807
895
|
entityId,
|
|
808
896
|
templateKey as TemplateKey,
|
|
809
|
-
enumId,
|
|
810
897
|
);
|
|
811
898
|
return {
|
|
812
899
|
entityId,
|
|
813
|
-
templateGroupName,
|
|
814
900
|
templateKey,
|
|
815
|
-
enumId,
|
|
816
901
|
subPath,
|
|
817
902
|
fullPath,
|
|
818
903
|
isExists,
|
|
@@ -990,6 +1075,327 @@ export async function sonamuUIApiPlugin(fastify: FastifyInstance) {
|
|
|
990
1075
|
return sonamuDictionary.checkUsage(request.body.keys);
|
|
991
1076
|
});
|
|
992
1077
|
|
|
1078
|
+
// Tasks API
|
|
1079
|
+
server.get("/api/tasks/status", async () => {
|
|
1080
|
+
try {
|
|
1081
|
+
Sonamu.workflows;
|
|
1082
|
+
return { active: true };
|
|
1083
|
+
} catch {
|
|
1084
|
+
return { active: false };
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
server.get("/api/tasks/workflowDefinitions", async () => {
|
|
1089
|
+
const definitions = Sonamu.workflows.workflowDefinitions;
|
|
1090
|
+
return { definitions };
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
server.get<{
|
|
1094
|
+
Querystring: {
|
|
1095
|
+
limit?: string;
|
|
1096
|
+
after?: string;
|
|
1097
|
+
before?: string;
|
|
1098
|
+
order?: "asc" | "desc";
|
|
1099
|
+
status?: string;
|
|
1100
|
+
workflowName?: string;
|
|
1101
|
+
createdAfter?: string;
|
|
1102
|
+
createdBefore?: string;
|
|
1103
|
+
};
|
|
1104
|
+
}>("/api/tasks/workflowRuns", async (request) => {
|
|
1105
|
+
const backend = Sonamu.workflows.backend;
|
|
1106
|
+
const { limit, after, before, order, status, workflowName, createdAfter, createdBefore } =
|
|
1107
|
+
request.query;
|
|
1108
|
+
return backend.listWorkflowRuns({
|
|
1109
|
+
limit: limit ? Number.parseInt(limit, 10) : undefined,
|
|
1110
|
+
after,
|
|
1111
|
+
before,
|
|
1112
|
+
order,
|
|
1113
|
+
status: status ? status.split(",") : undefined,
|
|
1114
|
+
workflowName: workflowName || undefined,
|
|
1115
|
+
createdAfter: createdAfter ? new Date(createdAfter) : undefined,
|
|
1116
|
+
createdBefore: createdBefore ? new Date(createdBefore) : undefined,
|
|
1117
|
+
});
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
server.get<{
|
|
1121
|
+
Params: { id: string };
|
|
1122
|
+
}>("/api/tasks/workflowRuns/:id", async (request) => {
|
|
1123
|
+
const backend = Sonamu.workflows.backend;
|
|
1124
|
+
const workflowRun = await backend.getWorkflowRun({
|
|
1125
|
+
workflowRunId: request.params.id,
|
|
1126
|
+
});
|
|
1127
|
+
if (!workflowRun) {
|
|
1128
|
+
throw new Error(`Workflow run not found: ${request.params.id}`);
|
|
1129
|
+
}
|
|
1130
|
+
return workflowRun;
|
|
1131
|
+
});
|
|
1132
|
+
|
|
1133
|
+
server.post<{
|
|
1134
|
+
Params: { id: string };
|
|
1135
|
+
}>("/api/tasks/workflowRuns/:id/cancel", async (request) => {
|
|
1136
|
+
const backend = Sonamu.workflows.backend;
|
|
1137
|
+
return backend.cancelWorkflowRun({
|
|
1138
|
+
workflowRunId: request.params.id,
|
|
1139
|
+
});
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1142
|
+
server.post<{
|
|
1143
|
+
Params: { id: string };
|
|
1144
|
+
}>("/api/tasks/workflowRuns/:id/pause", async (request) => {
|
|
1145
|
+
const backend = Sonamu.workflows.backend;
|
|
1146
|
+
return backend.pauseWorkflowRun({
|
|
1147
|
+
workflowRunId: request.params.id,
|
|
1148
|
+
});
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
server.post<{
|
|
1152
|
+
Params: { id: string };
|
|
1153
|
+
}>("/api/tasks/workflowRuns/:id/resume", async (request) => {
|
|
1154
|
+
const backend = Sonamu.workflows.backend;
|
|
1155
|
+
return backend.resumeWorkflowRun({
|
|
1156
|
+
workflowRunId: request.params.id,
|
|
1157
|
+
});
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
server.get<{
|
|
1161
|
+
Params: { id: string };
|
|
1162
|
+
Querystring: {
|
|
1163
|
+
limit?: string;
|
|
1164
|
+
after?: string;
|
|
1165
|
+
before?: string;
|
|
1166
|
+
};
|
|
1167
|
+
}>("/api/tasks/workflowRuns/:id/steps", async (request) => {
|
|
1168
|
+
const backend = Sonamu.workflows.backend;
|
|
1169
|
+
const { limit, after, before } = request.query;
|
|
1170
|
+
return backend.listStepAttempts({
|
|
1171
|
+
workflowRunId: request.params.id,
|
|
1172
|
+
limit: limit ? Number.parseInt(limit, 10) : undefined,
|
|
1173
|
+
after,
|
|
1174
|
+
before,
|
|
1175
|
+
});
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* Health Check API
|
|
1180
|
+
* MCP 도구가 Sonamu 서버를 자동 감지하기 위한 엔드포인트
|
|
1181
|
+
*/
|
|
1182
|
+
server.get("/api/sonamu/health", async (request) => {
|
|
1183
|
+
const address = request.server.server.address();
|
|
1184
|
+
const port = address && typeof address === "object" ? (address as AddressInfo).port : 0;
|
|
1185
|
+
|
|
1186
|
+
return {
|
|
1187
|
+
ok: true,
|
|
1188
|
+
project: process.cwd().split("/").pop() || "unknown",
|
|
1189
|
+
port,
|
|
1190
|
+
timestamp: new Date().toISOString(),
|
|
1191
|
+
};
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Fixture 생성 API
|
|
1196
|
+
*/
|
|
1197
|
+
server.post<{
|
|
1198
|
+
Body: {
|
|
1199
|
+
entity: string;
|
|
1200
|
+
count?: number;
|
|
1201
|
+
overrides?: Record<string, unknown>;
|
|
1202
|
+
targetDb?: "fixture" | "test";
|
|
1203
|
+
};
|
|
1204
|
+
}>("/api/sonamu/fixture/generate", async (request, reply) => {
|
|
1205
|
+
const { entity, count = 1, overrides, targetDb = "fixture" } = request.body;
|
|
1206
|
+
|
|
1207
|
+
try {
|
|
1208
|
+
// 타겟 DB 설정 가져오기
|
|
1209
|
+
const dbConfig = targetDb === "fixture" ? Sonamu.dbConfig.fixture : Sonamu.dbConfig.test;
|
|
1210
|
+
|
|
1211
|
+
// Knex 인스턴스 생성
|
|
1212
|
+
const db = createKnexInstance(dbConfig);
|
|
1213
|
+
|
|
1214
|
+
// FixtureGenerator 생성
|
|
1215
|
+
const generator = new FixtureGenerator(db, db, targetDb, EntityManager);
|
|
1216
|
+
|
|
1217
|
+
// 단일 Entity 배치 생성
|
|
1218
|
+
const fixtures = await generator.generateBatch([
|
|
1219
|
+
{
|
|
1220
|
+
entity,
|
|
1221
|
+
count,
|
|
1222
|
+
overrides: overrides ?? {},
|
|
1223
|
+
},
|
|
1224
|
+
]);
|
|
1225
|
+
|
|
1226
|
+
// Knex 연결 종료
|
|
1227
|
+
await db.destroy();
|
|
1228
|
+
|
|
1229
|
+
return {
|
|
1230
|
+
success: true,
|
|
1231
|
+
entity,
|
|
1232
|
+
count: fixtures.length,
|
|
1233
|
+
fixtures,
|
|
1234
|
+
targetDb,
|
|
1235
|
+
};
|
|
1236
|
+
} catch (error) {
|
|
1237
|
+
reply.status(400);
|
|
1238
|
+
return {
|
|
1239
|
+
success: false,
|
|
1240
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
});
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Fixture 데이터 탐색 API
|
|
1247
|
+
*/
|
|
1248
|
+
server.post<{
|
|
1249
|
+
Body: {
|
|
1250
|
+
entity: string;
|
|
1251
|
+
strategy: "sample" | "recent" | "random" | "query";
|
|
1252
|
+
limit?: number;
|
|
1253
|
+
where?: Record<string, unknown>;
|
|
1254
|
+
};
|
|
1255
|
+
}>("/api/sonamu/fixture/explore", async (request, reply) => {
|
|
1256
|
+
const { entity, strategy, limit = 10, where } = request.body;
|
|
1257
|
+
|
|
1258
|
+
try {
|
|
1259
|
+
// Fixture DB 설정 가져오기
|
|
1260
|
+
const fixtureDbConfig = Sonamu.dbConfig.fixture;
|
|
1261
|
+
|
|
1262
|
+
// Knex 인스턴스 생성
|
|
1263
|
+
const fixtureDb = createKnexInstance(fixtureDbConfig);
|
|
1264
|
+
|
|
1265
|
+
// DataExplorer 생성
|
|
1266
|
+
const explorer = new DataExplorer(fixtureDb, EntityManager);
|
|
1267
|
+
|
|
1268
|
+
const data = await explorer.explore(entity, {
|
|
1269
|
+
strategy,
|
|
1270
|
+
limit,
|
|
1271
|
+
where,
|
|
1272
|
+
});
|
|
1273
|
+
|
|
1274
|
+
// Knex 연결 종료
|
|
1275
|
+
await fixtureDb.destroy();
|
|
1276
|
+
|
|
1277
|
+
return {
|
|
1278
|
+
success: true,
|
|
1279
|
+
entity,
|
|
1280
|
+
strategy,
|
|
1281
|
+
count: data.length,
|
|
1282
|
+
data,
|
|
1283
|
+
};
|
|
1284
|
+
} catch (error) {
|
|
1285
|
+
reply.status(400);
|
|
1286
|
+
return {
|
|
1287
|
+
success: false,
|
|
1288
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* Fixture 데이터 가져오기 (fetch) API
|
|
1295
|
+
* production/development DB에서 실제 데이터를 fixture DB로 import
|
|
1296
|
+
*/
|
|
1297
|
+
server.post<{
|
|
1298
|
+
Body: {
|
|
1299
|
+
entity: string;
|
|
1300
|
+
strategy?: "sample" | "recent" | "random" | "query";
|
|
1301
|
+
limit?: number;
|
|
1302
|
+
includeRelations?: boolean;
|
|
1303
|
+
maxDepth?: number;
|
|
1304
|
+
};
|
|
1305
|
+
}>("/api/sonamu/fixture/fetch", async (request, reply) => {
|
|
1306
|
+
const {
|
|
1307
|
+
entity,
|
|
1308
|
+
strategy = "recent",
|
|
1309
|
+
limit = 10,
|
|
1310
|
+
includeRelations = true,
|
|
1311
|
+
maxDepth = 2,
|
|
1312
|
+
} = request.body;
|
|
1313
|
+
|
|
1314
|
+
try {
|
|
1315
|
+
// Source DB (production/development) - 읽기 전용
|
|
1316
|
+
const sourceDb = DB.getDB("r");
|
|
1317
|
+
|
|
1318
|
+
// Target DB (fixture)
|
|
1319
|
+
const fixtureDb = createKnexInstance(Sonamu.dbConfig.fixture);
|
|
1320
|
+
|
|
1321
|
+
// FixtureGenerator 생성
|
|
1322
|
+
const generator = new FixtureGenerator(sourceDb, fixtureDb, "fixture", EntityManager);
|
|
1323
|
+
|
|
1324
|
+
// production 데이터를 fixture DB로 import
|
|
1325
|
+
const results = await generator.importFromSource(entity, {
|
|
1326
|
+
strategy,
|
|
1327
|
+
limit,
|
|
1328
|
+
includeRelations,
|
|
1329
|
+
maxDepth,
|
|
1330
|
+
});
|
|
1331
|
+
|
|
1332
|
+
// Knex 연결 종료 (sourceDb는 Sonamu가 관리하므로 destroy하지 않음)
|
|
1333
|
+
await fixtureDb.destroy();
|
|
1334
|
+
|
|
1335
|
+
return {
|
|
1336
|
+
success: true,
|
|
1337
|
+
entity,
|
|
1338
|
+
strategy,
|
|
1339
|
+
count: results.length,
|
|
1340
|
+
imported: results,
|
|
1341
|
+
};
|
|
1342
|
+
} catch (error) {
|
|
1343
|
+
reply.status(400);
|
|
1344
|
+
return {
|
|
1345
|
+
success: false,
|
|
1346
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* Fixture 데이터 삭제 (clean) API
|
|
1353
|
+
* FK 순서를 고려하여 안전하게 삭제
|
|
1354
|
+
*/
|
|
1355
|
+
server.post<{
|
|
1356
|
+
Body: {
|
|
1357
|
+
entities?: string[];
|
|
1358
|
+
};
|
|
1359
|
+
}>("/api/sonamu/fixture/clean", async (request, reply) => {
|
|
1360
|
+
const { entities } = request.body;
|
|
1361
|
+
|
|
1362
|
+
try {
|
|
1363
|
+
// Fixture DB 연결
|
|
1364
|
+
const fixtureDb = createKnexInstance(Sonamu.dbConfig.fixture);
|
|
1365
|
+
|
|
1366
|
+
// 삭제할 Entity 목록 결정
|
|
1367
|
+
const targetEntities =
|
|
1368
|
+
entities && entities.length > 0 ? entities : EntityManager.getAllIds();
|
|
1369
|
+
|
|
1370
|
+
// Entity ID를 테이블명으로 변환 (snake_case 복수형)
|
|
1371
|
+
const tableNames = targetEntities.map((entityId) => {
|
|
1372
|
+
const entity = EntityManager.get(entityId);
|
|
1373
|
+
return entity.table;
|
|
1374
|
+
});
|
|
1375
|
+
|
|
1376
|
+
// PostgreSQL: TRUNCATE CASCADE로 FK 순서 무관하게 안전하게 삭제
|
|
1377
|
+
// CASCADE 옵션으로 의존성 있는 데이터도 함께 삭제
|
|
1378
|
+
await fixtureDb.raw(
|
|
1379
|
+
`TRUNCATE TABLE ${tableNames.map((t) => `"${t}"`).join(", ")} RESTART IDENTITY CASCADE`,
|
|
1380
|
+
);
|
|
1381
|
+
|
|
1382
|
+
// Knex 연결 종료
|
|
1383
|
+
await fixtureDb.destroy();
|
|
1384
|
+
|
|
1385
|
+
return {
|
|
1386
|
+
success: true,
|
|
1387
|
+
cleaned: tableNames,
|
|
1388
|
+
count: tableNames.length,
|
|
1389
|
+
};
|
|
1390
|
+
} catch (error) {
|
|
1391
|
+
reply.status(400);
|
|
1392
|
+
return {
|
|
1393
|
+
success: false,
|
|
1394
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
|
|
993
1399
|
// ui-web 빌드 파일 서빙
|
|
994
1400
|
const uiDistPath = path.resolve(import.meta.dirname, "../ui-web");
|
|
995
1401
|
|
package/src/utils/fs-utils.ts
CHANGED
|
@@ -38,11 +38,13 @@ export async function fileExists(path: PathLike): Promise<boolean> {
|
|
|
38
38
|
*
|
|
39
39
|
* @param fromPath 원본 파일 경로
|
|
40
40
|
* @param toPath 대상 파일 경로
|
|
41
|
+
* @param syncHeader 동기화 시 파일 최상단에 삽입할 주석 블록. 기존 @generated 블록이 있으면 교체하고, 없으면 최상단에 추가합니다.
|
|
41
42
|
* @returns 파일을 썼으면 true, 건너뛰었으면 false
|
|
42
43
|
*/
|
|
43
44
|
export async function copyFileWithReplaceCoreToShared(
|
|
44
45
|
fromPath: string,
|
|
45
46
|
toPath: string,
|
|
47
|
+
syncHeader?: string,
|
|
46
48
|
): Promise<boolean> {
|
|
47
49
|
if (!(await exists(fromPath))) {
|
|
48
50
|
return false;
|
|
@@ -50,7 +52,7 @@ export async function copyFileWithReplaceCoreToShared(
|
|
|
50
52
|
|
|
51
53
|
const oldFileContent = (await readFile(fromPath)).toString();
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
let newFileContent = (() => {
|
|
54
56
|
// sonamu.shared.ts는 항상 {base}/src/services/sonamu.shared.ts에 위치합니다.
|
|
55
57
|
// toPath에서 /src/를 찾아 services 디렉토리 경로를 계산합니다.
|
|
56
58
|
const srcMatch = toPath.match(/^(.+\/src)\//);
|
|
@@ -67,6 +69,17 @@ export async function copyFileWithReplaceCoreToShared(
|
|
|
67
69
|
return oldFileContent.replace(/from "sonamu(\/dict)?"/g, `from "${sharedPath}"`);
|
|
68
70
|
})();
|
|
69
71
|
|
|
72
|
+
// syncHeader가 제공된 경우 @generated 블록을 교체하거나 최상단에 추가합니다.
|
|
73
|
+
if (syncHeader) {
|
|
74
|
+
// 여러 줄 형식만 매칭합니다. 한 줄짜리(/** @generated */)는 매칭하지 않으므로 수동으로 축약하지 마세요.
|
|
75
|
+
const generatedBlockRegex = /\/\*\*\r?\n \* @generated\r?\n[\s\S]*?\*\/\r?\n/;
|
|
76
|
+
if (generatedBlockRegex.test(newFileContent)) {
|
|
77
|
+
newFileContent = newFileContent.replace(generatedBlockRegex, `${syncHeader}\n`);
|
|
78
|
+
} else {
|
|
79
|
+
newFileContent = `${syncHeader}\n${newFileContent}`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
70
83
|
await writeFile(toPath, newFileContent);
|
|
71
84
|
return true;
|
|
72
85
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
-
import type { TemplateOptions } from "../../types/types";
|
|
3
|
-
import { Template } from "../template";
|
|
4
|
-
export declare class Template__view_enums_select extends Template {
|
|
5
|
-
constructor();
|
|
6
|
-
getTargetAndPath(names: EntityNamesRecord, enumId: string): {
|
|
7
|
-
target: string;
|
|
8
|
-
path: string;
|
|
9
|
-
};
|
|
10
|
-
render({ entityId, enumId }: TemplateOptions["view_enums_select"]): Promise<{
|
|
11
|
-
body: string;
|
|
12
|
-
importKeys: never[];
|
|
13
|
-
target: string;
|
|
14
|
-
path: string;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=view_enums_select.template.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view_enums_select.template.d.ts","sourceRoot":"","sources":["../../../src/template/implementations/view_enums_select.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,2BAA4B,SAAQ,QAAQ;;IAKvD,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM;;;;IAOnD,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,mBAAmB,CAAC;;;;;;CA+CxE"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { EntityManager } from "../../entity/entity-manager.js";
|
|
2
|
-
import { getLabel } from "../helpers.js";
|
|
3
|
-
import { Template } from "../template.js";
|
|
4
|
-
export class Template__view_enums_select extends Template {
|
|
5
|
-
constructor(){
|
|
6
|
-
super("view_enums_select");
|
|
7
|
-
}
|
|
8
|
-
getTargetAndPath(names, enumId) {
|
|
9
|
-
return {
|
|
10
|
-
target: "web/src/components",
|
|
11
|
-
path: `${names.fs}/${enumId}Select.tsx`
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
async render({ entityId, enumId }) {
|
|
15
|
-
const names = EntityManager.getNamesFromId(entityId);
|
|
16
|
-
const label = getLabel(entityId, enumId);
|
|
17
|
-
return {
|
|
18
|
-
...this.getTargetAndPath(names, enumId),
|
|
19
|
-
body: `
|
|
20
|
-
import { EnumSelect } from '@sonamu-kit/react-components/components';
|
|
21
|
-
import { ${enumId}, ${enumId}Label } from '@/services/sonamu.generated';
|
|
22
|
-
|
|
23
|
-
export type ${enumId}SelectProps = {
|
|
24
|
-
value?: string;
|
|
25
|
-
onValueChange?: (value: string | null | undefined) => void;
|
|
26
|
-
placeholder?: string;
|
|
27
|
-
textPrefix?: string;
|
|
28
|
-
clearable?: boolean;
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
className?: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export function ${enumId}Select({
|
|
34
|
-
value,
|
|
35
|
-
onValueChange,
|
|
36
|
-
placeholder,
|
|
37
|
-
textPrefix,
|
|
38
|
-
clearable,
|
|
39
|
-
disabled,
|
|
40
|
-
className,
|
|
41
|
-
}: ${enumId}SelectProps) {
|
|
42
|
-
return (
|
|
43
|
-
<EnumSelect
|
|
44
|
-
enum={${enumId}}
|
|
45
|
-
labels={${enumId}Label}
|
|
46
|
-
value={value}
|
|
47
|
-
onValueChange={onValueChange}
|
|
48
|
-
placeholder={placeholder ?? "${label}"}
|
|
49
|
-
textPrefix={textPrefix}
|
|
50
|
-
clearable={clearable}
|
|
51
|
-
disabled={disabled}
|
|
52
|
-
className={className}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
`.trim(),
|
|
57
|
-
importKeys: []
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90ZW1wbGF0ZS9pbXBsZW1lbnRhdGlvbnMvdmlld19lbnVtc19zZWxl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QUFDRixnQkFBZ0IsQ0FBQ0MsT0FBT0MsT0FBTztZQUN2Q1EsTUFBTSxDQUFDOztTQUVKLEVBQUVSLE9BQU8sRUFBRSxFQUFFQSxPQUFPOztZQUVqQixFQUFFQSxPQUFPOzs7Ozs7Ozs7O2dCQVVMLEVBQUVBLE9BQU87Ozs7Ozs7O0dBUXRCLEVBQUVBLE9BQU87OztZQUdBLEVBQUVBLE9BQU87Y0FDUCxFQUFFQSxPQUFPOzs7bUNBR1ksRUFBRU8sTUFBTTs7Ozs7Ozs7TUFRckMsQ0FBQyxDQUFDRSxJQUFJO1lBQ05DLFlBQVksRUFBRTtRQUNoQjtJQUNGO0FBQ0YifQ==
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
-
import type { TemplateOptions } from "../../types/types";
|
|
3
|
-
import { Template } from "../template";
|
|
4
|
-
export declare class Template__view_id_async_select extends Template {
|
|
5
|
-
constructor();
|
|
6
|
-
getTargetAndPath(names: EntityNamesRecord): {
|
|
7
|
-
target: string;
|
|
8
|
-
path: string;
|
|
9
|
-
};
|
|
10
|
-
render({ entityId, textField }: TemplateOptions["view_id_async_select"]): {
|
|
11
|
-
body: string;
|
|
12
|
-
importKeys: never[];
|
|
13
|
-
target: string;
|
|
14
|
-
path: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=view_id_async_select.template.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view_id_async_select.template.d.ts","sourceRoot":"","sources":["../../../src/template/implementations/view_id_async_select.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,8BAA+B,SAAQ,QAAQ;;IAK1D,gBAAgB,CAAC,KAAK,EAAE,iBAAiB;;;;IAOzC,MAAM,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,eAAe,CAAC,sBAAsB,CAAC;;;;;;CA0HxE"}
|