create-entity-server 0.0.9

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.
Files changed (63) hide show
  1. package/bin/create.js +280 -0
  2. package/package.json +42 -0
  3. package/template/.env.example +14 -0
  4. package/template/configs/cache.json +22 -0
  5. package/template/configs/cors.json +7 -0
  6. package/template/configs/database.json +23 -0
  7. package/template/configs/jwt.json +7 -0
  8. package/template/configs/logging.json +45 -0
  9. package/template/configs/security.json +21 -0
  10. package/template/configs/server.json +10 -0
  11. package/template/entities/Account/account_audit.json +17 -0
  12. package/template/entities/Auth/account.json +60 -0
  13. package/template/entities/Auth/api_keys.json +26 -0
  14. package/template/entities/Auth/license.json +36 -0
  15. package/template/entities/Auth/rbac_roles.json +76 -0
  16. package/template/entities/README.md +380 -0
  17. package/template/entities/System/system_audit_log.json +65 -0
  18. package/template/entities/company.json +22 -0
  19. package/template/entities/product.json +36 -0
  20. package/template/entities/todo.json +16 -0
  21. package/template/samples/README.md +65 -0
  22. package/template/samples/flutter/lib/entity_server_client.dart +218 -0
  23. package/template/samples/flutter/pubspec.yaml +14 -0
  24. package/template/samples/java/EntityServerClient.java +304 -0
  25. package/template/samples/java/EntityServerExample.java +49 -0
  26. package/template/samples/kotlin/EntityServerClient.kt +194 -0
  27. package/template/samples/node/package.json +16 -0
  28. package/template/samples/node/src/EntityServerClient.js +246 -0
  29. package/template/samples/node/src/example.js +39 -0
  30. package/template/samples/php/ci4/Controllers/ProductController.php +141 -0
  31. package/template/samples/php/ci4/Libraries/EntityServer.php +260 -0
  32. package/template/samples/php/laravel/Http/Controllers/ProductController.php +62 -0
  33. package/template/samples/php/laravel/Services/EntityServerService.php +210 -0
  34. package/template/samples/python/entity_server.py +225 -0
  35. package/template/samples/python/example.py +50 -0
  36. package/template/samples/react/src/api/entityServerClient.ts +290 -0
  37. package/template/samples/react/src/example.tsx +127 -0
  38. package/template/samples/react/src/hooks/useEntity.ts +105 -0
  39. package/template/samples/swift/EntityServerClient.swift +221 -0
  40. package/template/scripts/api-key.ps1 +123 -0
  41. package/template/scripts/api-key.sh +130 -0
  42. package/template/scripts/cleanup-history.ps1 +69 -0
  43. package/template/scripts/cleanup-history.sh +54 -0
  44. package/template/scripts/cli.ps1 +24 -0
  45. package/template/scripts/cli.sh +27 -0
  46. package/template/scripts/entity.ps1 +70 -0
  47. package/template/scripts/entity.sh +72 -0
  48. package/template/scripts/generate-env-keys.ps1 +125 -0
  49. package/template/scripts/generate-env-keys.sh +148 -0
  50. package/template/scripts/install-systemd.sh +222 -0
  51. package/template/scripts/normalize-entities.ps1 +87 -0
  52. package/template/scripts/normalize-entities.sh +132 -0
  53. package/template/scripts/rbac-role.ps1 +124 -0
  54. package/template/scripts/rbac-role.sh +127 -0
  55. package/template/scripts/remove-systemd.sh +158 -0
  56. package/template/scripts/reset-all.ps1 +83 -0
  57. package/template/scripts/reset-all.sh +95 -0
  58. package/template/scripts/run.ps1 +239 -0
  59. package/template/scripts/run.sh +315 -0
  60. package/template/scripts/sync.ps1 +145 -0
  61. package/template/scripts/sync.sh +178 -0
  62. package/template/scripts/update-server.ps1 +117 -0
  63. package/template/scripts/update-server.sh +165 -0
@@ -0,0 +1,127 @@
1
+ #!/bin/bash
2
+ # RBAC 역할 관리 스크립트 (CLI 바이너리 직접 호출)
3
+ # 서버가 중단된 상태에서도 사용 가능합니다.
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
7
+ BIN_PATH="$PROJECT_ROOT/bin/entity-cli"
8
+
9
+ cd "$PROJECT_ROOT"
10
+
11
+ # Load language from .env
12
+ if [ -f .env ]; then
13
+ LANGUAGE=$(grep '^LANGUAGE=' .env | cut -d '=' -f2)
14
+ fi
15
+ LANGUAGE=${LANGUAGE:-ko}
16
+
17
+ show_help() {
18
+ if [ "$LANGUAGE" = "en" ]; then
19
+ echo "RBAC Role Management (CLI mode)"
20
+ echo "================================"
21
+ echo ""
22
+ echo "Manage rbac_roles entity directly via CLI binary."
23
+ echo "Server does NOT need to be running."
24
+ echo ""
25
+ echo "Usage: $0 <subcommand> [options]"
26
+ echo ""
27
+ echo "Subcommands:"
28
+ echo " list List RBAC roles"
29
+ echo " add Create a new role"
30
+ echo " delete Delete a role by name or seq"
31
+ echo " help Show this help"
32
+ echo ""
33
+ echo "list options:"
34
+ echo " --limit=<n> Max rows to show (default: 50)"
35
+ echo ""
36
+ echo "add options:"
37
+ echo " --name=<name> Role name (required, unique)"
38
+ echo " --permissions=<j> Permissions JSON array (default: [\"entity:read\",\"entity:list\"])"
39
+ echo " --description=<t> Description"
40
+ echo " --apply Execute (default is dry-run)"
41
+ echo ""
42
+ echo "delete options:"
43
+ echo " --name=<name> Role name to delete"
44
+ echo " --seq=<n> Role seq to delete"
45
+ echo " --apply Execute (default is dry-run)"
46
+ echo ""
47
+ echo "Examples:"
48
+ echo " $0 list"
49
+ echo " $0 add --name=readonly --permissions='[\"entity:read\",\"entity:list\"]' --apply"
50
+ echo " $0 add --name=fullaccess --permissions='[\"*\"]' --description=\"Full access\" --apply"
51
+ echo " $0 delete --name=readonly --apply"
52
+ echo " $0 delete --seq=5 --apply"
53
+ else
54
+ echo "RBAC 역할 관리 (CLI 모드)"
55
+ echo "======================"
56
+ echo ""
57
+ echo "CLI 바이너리로 rbac_roles 엔티티를 직접 조작합니다."
58
+ echo "서버가 실행 중이지 않아도 사용 가능합니다."
59
+ echo ""
60
+ echo "사용법: $0 <하위명령> [옵션]"
61
+ echo ""
62
+ echo "하위 명령:"
63
+ echo " list RBAC 역할 목록 조회"
64
+ echo " add 새 역할 추가"
65
+ echo " delete 역할 삭제 (이름 또는 seq 지정)"
66
+ echo " help 도움말 출력"
67
+ echo ""
68
+ echo "list 옵션:"
69
+ echo " --limit=<n> 최대 출력 행 수 (기본: 50)"
70
+ echo ""
71
+ echo "add 옵션:"
72
+ echo " --name=<이름> 역할 이름 (필수, unique)"
73
+ echo " --permissions=<j> 권한 JSON 배열 (기본: [\"entity:read\",\"entity:list\"])"
74
+ echo " --description=<t> 설명"
75
+ echo " --apply 실제 실행 (기본: dry-run)"
76
+ echo ""
77
+ echo "delete 옵션:"
78
+ echo " --name=<이름> 삭제할 역할 이름"
79
+ echo " --seq=<n> 삭제할 역할 seq"
80
+ echo " --apply 실제 실행 (기본: dry-run)"
81
+ echo ""
82
+ echo "예제:"
83
+ echo " $0 list"
84
+ echo " $0 add --name=readonly --permissions='[\"entity:read\",\"entity:list\"]' --apply"
85
+ echo " $0 add --name=fullaccess --permissions='[\"*\"]' --description=\"전체 권한\" --apply"
86
+ echo " $0 delete --name=readonly --apply"
87
+ echo " $0 delete --seq=5 --apply"
88
+ fi
89
+ }
90
+
91
+ # 인자 없으면 도움말
92
+ if [ $# -eq 0 ]; then
93
+ show_help
94
+ exit 0
95
+ fi
96
+
97
+ # CLI 바이너리 존재 확인
98
+ if [ ! -f "$BIN_PATH" ]; then
99
+ if [ "$LANGUAGE" = "en" ]; then
100
+ echo "❌ bin/entity-cli not found. Run: ./scripts/build.sh"
101
+ else
102
+ echo "❌ bin/entity-cli 파일이 없습니다. 먼저 ./scripts/build.sh 를 실행하세요."
103
+ fi
104
+ exit 1
105
+ fi
106
+
107
+ SUBCOMMAND="$1"
108
+ shift
109
+
110
+ case "$SUBCOMMAND" in
111
+ list|show|add|delete)
112
+ ENTITY_CLI_NAME="rbac-role" "$BIN_PATH" rbac-role "$SUBCOMMAND" "$@"
113
+ ;;
114
+ help|-h|--help)
115
+ show_help
116
+ ;;
117
+ *)
118
+ if [ "$LANGUAGE" = "en" ]; then
119
+ echo "❌ Unknown subcommand: $SUBCOMMAND"
120
+ else
121
+ echo "❌ 알 수 없는 하위 명령: $SUBCOMMAND"
122
+ fi
123
+ echo ""
124
+ show_help
125
+ exit 1
126
+ ;;
127
+ esac
@@ -0,0 +1,158 @@
1
+ #!/bin/bash
2
+
3
+ # Remove entity-server systemd service.
4
+
5
+ set -e
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
9
+
10
+ # Load language from .env
11
+ if [ -f "$PROJECT_ROOT/.env" ]; then
12
+ LANGUAGE=$(grep '^LANGUAGE=' "$PROJECT_ROOT/.env" | cut -d '=' -f2)
13
+ fi
14
+ LANGUAGE=${LANGUAGE:-ko}
15
+
16
+ SERVICE_NAME="entity-server"
17
+ INTERACTIVE=false
18
+ CONFIRMED=false
19
+ SERVER_CONFIG="$PROJECT_ROOT/configs/server.json"
20
+
21
+ load_namespace() {
22
+ local namespace=""
23
+ if [ -f "$SERVER_CONFIG" ]; then
24
+ namespace=$(sed -n 's/.*"namespace"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$SERVER_CONFIG" | head -n 1)
25
+ fi
26
+ namespace=$(echo "$namespace" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_-]/-/g')
27
+ if [ -z "$namespace" ]; then
28
+ namespace="default"
29
+ fi
30
+ SERVICE_NAME="${namespace}-entity-server"
31
+ }
32
+
33
+ load_namespace
34
+
35
+ show_help() {
36
+ if [ "$LANGUAGE" = "en" ]; then
37
+ echo "Remove systemd service for Entity Server"
38
+ echo "======================================="
39
+ echo ""
40
+ echo "Usage: $0 [options]"
41
+ echo ""
42
+ echo "Service name is auto-generated as '<namespace>-entity-server'."
43
+ echo "Run without arguments to enter interactive mode."
44
+ else
45
+ echo "Entity Server systemd 서비스 제거"
46
+ echo "==============================="
47
+ echo ""
48
+ echo "사용법: $0"
49
+ echo ""
50
+ echo "서비스명은 '<namespace>-entity-server' 형식으로 자동 생성됩니다."
51
+ echo "인수 없이 실행하면 인터랙티브 모드로 진입합니다."
52
+ fi
53
+ }
54
+
55
+ if [ $# -eq 0 ]; then
56
+ INTERACTIVE=true
57
+ fi
58
+
59
+ for arg in "$@"; do
60
+ case "$arg" in
61
+ --yes|-y)
62
+ CONFIRMED=true
63
+ ;;
64
+ *)
65
+ if [ "$LANGUAGE" = "en" ]; then
66
+ echo "❌ Unknown option: $arg"
67
+ echo " Service name is fixed: $SERVICE_NAME"
68
+ else
69
+ echo "❌ 알 수 없는 옵션: $arg"
70
+ echo " 서비스명은 자동 고정값입니다: $SERVICE_NAME"
71
+ fi
72
+ exit 1
73
+ ;;
74
+ esac
75
+ done
76
+
77
+ if [ "$INTERACTIVE" = true ] && [ "$CONFIRMED" = false ]; then
78
+ if [ "$LANGUAGE" = "en" ]; then
79
+ echo "[interactive] systemd service removal"
80
+ echo "service name: $SERVICE_NAME"
81
+ else
82
+ echo "[interactive] systemd 서비스 제거"
83
+ echo "서비스명: $SERVICE_NAME"
84
+ fi
85
+
86
+ if [ "$LANGUAGE" = "en" ]; then
87
+ read -r -p "Remove service '$SERVICE_NAME'? [y/N]: " input
88
+ else
89
+ read -r -p "'$SERVICE_NAME' 서비스를 제거할까요? [y/N]: " input
90
+ fi
91
+ input=$(echo "$input" | tr '[:upper:]' '[:lower:]')
92
+ if [ "$input" != "y" ] && [ "$input" != "yes" ]; then
93
+ if [ "$LANGUAGE" = "en" ]; then
94
+ echo "Canceled."
95
+ else
96
+ echo "취소되었습니다."
97
+ fi
98
+ exit 0
99
+ fi
100
+ fi
101
+
102
+ UNIT_PATH="/etc/systemd/system/${SERVICE_NAME}.service"
103
+
104
+ if [ "$EUID" -ne 0 ]; then
105
+ if command -v sudo >/dev/null 2>&1; then
106
+ exec sudo "$0" --yes
107
+ fi
108
+ if [ "$LANGUAGE" = "en" ]; then
109
+ echo "❌ This script requires root privileges"
110
+ else
111
+ echo "❌ 이 스크립트는 root 권한이 필요합니다"
112
+ fi
113
+ exit 1
114
+ fi
115
+
116
+ SERVICE_EXISTS=false
117
+ if systemctl list-unit-files | grep -q "^${SERVICE_NAME}\.service"; then
118
+ SERVICE_EXISTS=true
119
+ fi
120
+ if [ ! -f "$UNIT_PATH" ] && [ "$SERVICE_EXISTS" = false ]; then
121
+ if [ "$LANGUAGE" = "en" ]; then
122
+ echo "ℹ️ Service '$SERVICE_NAME' is not registered."
123
+ echo " Nothing to remove."
124
+ echo ""
125
+ echo " To register the service, run:"
126
+ echo " sudo $(dirname "$0")/install-systemd.sh"
127
+ else
128
+ echo "ℹ️ '$SERVICE_NAME' 서비스가 등록되어 있지 않습니다."
129
+ echo " 제거할 항목이 없습니다."
130
+ echo ""
131
+ echo " 서비스를 등록하려면:"
132
+ echo " sudo $(dirname "$0")/install-systemd.sh"
133
+ fi
134
+ exit 0
135
+ fi
136
+
137
+ if [ "$SERVICE_EXISTS" = true ]; then
138
+ systemctl stop "$SERVICE_NAME" 2>/dev/null || true
139
+ systemctl disable "$SERVICE_NAME" 2>/dev/null || true
140
+ fi
141
+
142
+ if [ -f "$UNIT_PATH" ]; then
143
+ rm -f "$UNIT_PATH"
144
+ fi
145
+
146
+ systemctl daemon-reload
147
+
148
+ if [ "$LANGUAGE" = "en" ]; then
149
+ echo "✅ Service removed: $SERVICE_NAME"
150
+ echo ""
151
+ echo " To re-register the service, run:"
152
+ echo " sudo $(dirname "$0")/install-systemd.sh"
153
+ else
154
+ echo "✅ 서비스 제거 완료: $SERVICE_NAME"
155
+ echo ""
156
+ echo " 서비스를 다시 등록하려면:"
157
+ echo " sudo $(dirname "$0")/install-systemd.sh"
158
+ fi
@@ -0,0 +1,83 @@
1
+ # Reset All Entity Tables - Windows PowerShell
2
+ # Drop all entity tables and recreate with default data
3
+ param(
4
+ [switch]$DryRun,
5
+ [switch]$Apply,
6
+ [switch]$Force
7
+ )
8
+
9
+ $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
10
+ $ProjectRoot = Split-Path -Parent $ScriptDir
11
+
12
+ Set-Location $ProjectRoot
13
+
14
+ # Load language from .env
15
+ $Language = "ko"
16
+ $EnvFile = Join-Path $ProjectRoot ".env"
17
+ if (Test-Path $EnvFile) {
18
+ $LangLine = Get-Content $EnvFile | Where-Object { $_ -match '^LANGUAGE=' } | Select-Object -First 1
19
+ if ($LangLine) { $Language = $LangLine -replace '^LANGUAGE=', '' }
20
+ }
21
+
22
+ if (-not $DryRun -and -not $Apply -and -not $Force) {
23
+ if ($Language -eq "en") {
24
+ Write-Host "Reset All Entity Tables"
25
+ Write-Host "======================="
26
+ Write-Host ""
27
+ Write-Host "Drop all entity tables and recreate with default data."
28
+ Write-Host ""
29
+ Write-Host "Usage: .\reset-all.ps1 [OPTIONS]"
30
+ Write-Host ""
31
+ Write-Host "Options:"
32
+ Write-Host " -DryRun Preview mode - show what will be deleted"
33
+ Write-Host " -Apply Apply changes with confirmation prompt"
34
+ Write-Host " -Force Apply changes without confirmation"
35
+ Write-Host ""
36
+ Write-Host "Examples:"
37
+ Write-Host " .\reset-all.ps1 -DryRun # See what will happen"
38
+ Write-Host " .\reset-all.ps1 -Apply # Execute with confirmation"
39
+ Write-Host " .\reset-all.ps1 -Force # Execute immediately (dangerous!)"
40
+ } else {
41
+ Write-Host "모든 엔티티 테이블 초기화"
42
+ Write-Host "====================="
43
+ Write-Host ""
44
+ Write-Host "모든 entity 테이블을 삭제하고 기본 데이터로 재생성합니다."
45
+ Write-Host ""
46
+ Write-Host "사용법: .\reset-all.ps1 [옵션]"
47
+ Write-Host ""
48
+ Write-Host "옵션:"
49
+ Write-Host " -DryRun 미리보기 모드 - 삭제될 테이블 확인"
50
+ Write-Host " -Apply 확인 후 실행"
51
+ Write-Host " -Force 확인 없이 즉시 실행"
52
+ Write-Host ""
53
+ Write-Host "예제:"
54
+ Write-Host " .\reset-all.ps1 -DryRun # 미리보기"
55
+ Write-Host " .\reset-all.ps1 -Apply # 확인 후 실행"
56
+ Write-Host " .\reset-all.ps1 -Force # 즉시 실행 (위험!)"
57
+ }
58
+ exit 0
59
+ }
60
+
61
+ $CliBin = Join-Path $ProjectRoot "bin\entity-cli.exe"
62
+ if (-not (Test-Path $CliBin)) {
63
+ if ($Language -eq "en") { Write-Host "X bin/entity-cli.exe not found" }
64
+ else { Write-Host "X bin/entity-cli.exe 파일이 없습니다" }
65
+ exit 1
66
+ }
67
+
68
+ if ($DryRun) {
69
+ & $CliBin reset-all
70
+ } elseif ($Force -or $Apply) {
71
+ # 필수 엔티티 없으면 자동 생성 (api_keys, rbac_roles, account, user)
72
+ $NormalizePs1 = Join-Path $ScriptDir "normalize-entities.ps1"
73
+ if ($Language -eq "en") { Write-Host "⚙️ Checking required entities..." }
74
+ else { Write-Host "⚙️ 필수 엔티티 확인 중..." }
75
+ $env:LANGUAGE = $Language
76
+ & $NormalizePs1 -Apply
77
+
78
+ if ($Force) {
79
+ & $CliBin reset-all --apply --force
80
+ } else {
81
+ & $CliBin reset-all --apply
82
+ }
83
+ }
@@ -0,0 +1,95 @@
1
+ #!/bin/bash
2
+
3
+ # Reset all entity tables and seed default data
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
7
+
8
+ cd "$PROJECT_ROOT"
9
+
10
+ # Load language from .env
11
+ if [ -f .env ]; then
12
+ LANGUAGE=$(grep '^LANGUAGE=' .env | cut -d '=' -f2)
13
+ fi
14
+ LANGUAGE=${LANGUAGE:-ko}
15
+
16
+ # Show usage if no arguments
17
+ if [ $# -eq 0 ]; then
18
+ if [ "$LANGUAGE" = "en" ]; then
19
+ echo "Reset All Entity Tables"
20
+ echo "======================="
21
+ echo ""
22
+ echo "Drop all entity tables and recreate with default data."
23
+ echo ""
24
+ echo "Usage: $0 [OPTIONS]"
25
+ echo ""
26
+ echo "Options:"
27
+ echo " --dry-run Preview mode - show what will be deleted"
28
+ echo " --apply Apply changes with confirmation prompt"
29
+ echo " --force Apply changes without confirmation"
30
+ echo ""
31
+ echo "Examples:"
32
+ echo " $0 --dry-run # See what will happen"
33
+ echo " $0 --apply # Execute with confirmation"
34
+ echo " $0 --force # Execute immediately (dangerous!)"
35
+ else
36
+ echo "모든 엔티티 테이블 초기화"
37
+ echo "====================="
38
+ echo ""
39
+ echo "모든 entity 테이블을 삭제하고 기본 데이터로 재생성합니다."
40
+ echo ""
41
+ echo "사용법: $0 [옵션]"
42
+ echo ""
43
+ echo "옵션:"
44
+ echo " --dry-run 미리보기 모드 - 삭제될 테이블 확인"
45
+ echo " --apply 확인 후 실행"
46
+ echo " --force 확인 없이 즉시 실행"
47
+ echo ""
48
+ echo "예제:"
49
+ echo " $0 --dry-run # 미리보기"
50
+ echo " $0 --apply # 확인 후 실행"
51
+ echo " $0 --force # 즉시 실행 (위험!)"
52
+ fi
53
+ exit 0
54
+ fi
55
+
56
+ # Require prebuilt CLI binary
57
+ if [ ! -f "$PROJECT_ROOT/bin/entity-cli" ]; then
58
+ if [ "$LANGUAGE" = "en" ]; then
59
+ echo "❌ bin/entity-cli not found"
60
+ else
61
+ echo "❌ bin/entity-cli 파일이 없습니다"
62
+ fi
63
+ exit 1
64
+ fi
65
+
66
+ # Execute based on flag
67
+ case "$1" in
68
+ --dry-run)
69
+ "$PROJECT_ROOT/bin/entity-cli" reset-all
70
+ ;;
71
+ --force|--apply)
72
+ # 필수 엔티티 없으면 자동 생성 (api_keys, rbac_roles, account, user)
73
+ if [ "$LANGUAGE" = "en" ]; then
74
+ echo "⚙️ Checking required entities..."
75
+ else
76
+ echo "⚙️ 필수 엔티티 확인 중..."
77
+ fi
78
+ LANGUAGE="$LANGUAGE" "$SCRIPT_DIR/normalize-entities.sh" --apply
79
+ if [ "$1" = "--force" ]; then
80
+ "$PROJECT_ROOT/bin/entity-cli" reset-all --apply --force
81
+ else
82
+ "$PROJECT_ROOT/bin/entity-cli" reset-all --apply
83
+ fi
84
+ ;;
85
+ *)
86
+ if [ "$LANGUAGE" = "en" ]; then
87
+ echo "❌ Unknown option: $1"
88
+ echo "Run '$0' for usage information"
89
+ else
90
+ echo "❌ 알 수 없는 옵션: $1"
91
+ echo "'$0'로 사용법을 확인하세요"
92
+ fi
93
+ exit 1
94
+ ;;
95
+ esac