com.backnd.database 0.0.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.
Files changed (63) hide show
  1. package/Attributes/ColumnAttribute.cs +46 -0
  2. package/Attributes/ColumnAttribute.cs.meta +11 -0
  3. package/Attributes/PrimaryKeyAttribute.cs +12 -0
  4. package/Attributes/PrimaryKeyAttribute.cs.meta +11 -0
  5. package/Attributes/TableAttribute.cs +44 -0
  6. package/Attributes/TableAttribute.cs.meta +11 -0
  7. package/Attributes.meta +8 -0
  8. package/BACKND.Database.asmdef +14 -0
  9. package/BACKND.Database.asmdef.meta +7 -0
  10. package/BaseModel.cs +22 -0
  11. package/BaseModel.cs.meta +11 -0
  12. package/Client.cs +490 -0
  13. package/Client.cs.meta +11 -0
  14. package/Editor/BACKND.Database.Editor.asmdef +18 -0
  15. package/Editor/BACKND.Database.Editor.asmdef.meta +7 -0
  16. package/Editor/PackageAssetInstaller.cs +251 -0
  17. package/Editor/PackageAssetInstaller.cs.meta +11 -0
  18. package/Editor.meta +8 -0
  19. package/Exceptions/DatabaseException.cs +34 -0
  20. package/Exceptions/DatabaseException.cs.meta +11 -0
  21. package/Exceptions.meta +8 -0
  22. package/Internal/ExpressionAnalyzer.cs +433 -0
  23. package/Internal/ExpressionAnalyzer.cs.meta +11 -0
  24. package/Internal/QueryTypes.cs +61 -0
  25. package/Internal/QueryTypes.cs.meta +11 -0
  26. package/Internal/SqlBuilder.cs +375 -0
  27. package/Internal/SqlBuilder.cs.meta +11 -0
  28. package/Internal/ValueFormatter.cs +103 -0
  29. package/Internal/ValueFormatter.cs.meta +11 -0
  30. package/Internal.meta +8 -0
  31. package/Network/DatabaseExecutor.cs +171 -0
  32. package/Network/DatabaseExecutor.cs.meta +11 -0
  33. package/Network/DatabaseRequest.cs +16 -0
  34. package/Network/DatabaseRequest.cs.meta +11 -0
  35. package/Network/DatabaseResponse.cs +81 -0
  36. package/Network/DatabaseResponse.cs.meta +11 -0
  37. package/Network.meta +8 -0
  38. package/QueryBuilder.cs +1001 -0
  39. package/QueryBuilder.cs.meta +11 -0
  40. package/README.md +24 -0
  41. package/TheBackend~/Plugins/Android/Backend.aar +0 -0
  42. package/TheBackend~/Plugins/Backend.dll +0 -0
  43. package/TheBackend~/Plugins/Editor/TheBackendMultiSettingEditor.dll +0 -0
  44. package/TheBackend~/Plugins/Editor/TheBackendSettingEditor.dll +0 -0
  45. package/TheBackend~/Plugins/LitJSON.dll +0 -0
  46. package/TheBackend~/Plugins/Settings/TheBackendHashKeySettings.dll +0 -0
  47. package/TheBackend~/Plugins/Settings/TheBackendMultiSettings.dll +0 -0
  48. package/TheBackend~/Plugins/Settings/TheBackendSettings.dll +0 -0
  49. package/Tools/BTask.cs +905 -0
  50. package/Tools/BTask.cs.meta +11 -0
  51. package/Tools/DatabaseLoop.cs +110 -0
  52. package/Tools/DatabaseLoop.cs.meta +11 -0
  53. package/Tools/JsonHelper.cs +82 -0
  54. package/Tools/JsonHelper.cs.meta +11 -0
  55. package/Tools.meta +8 -0
  56. package/TransactionBuilder.cs +154 -0
  57. package/TransactionBuilder.cs.meta +11 -0
  58. package/TransactionQueryBuilder.cs +205 -0
  59. package/TransactionQueryBuilder.cs.meta +11 -0
  60. package/TransactionResult.cs +33 -0
  61. package/TransactionResult.cs.meta +11 -0
  62. package/package.json +20 -0
  63. package/package.json.meta +7 -0
package/Client.cs.meta ADDED
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 47a2b84df55494bb8942fc342120e806
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "BACKND.Database.Editor",
3
+ "rootNamespace": "BACKND.Database.Editor",
4
+ "references": [
5
+ "BACKND.Database"
6
+ ],
7
+ "includePlatforms": [
8
+ "Editor"
9
+ ],
10
+ "excludePlatforms": [],
11
+ "allowUnsafeCode": false,
12
+ "overrideReferences": false,
13
+ "precompiledReferences": [],
14
+ "autoReferenced": true,
15
+ "defineConstraints": [],
16
+ "versionDefines": [],
17
+ "noEngineReferences": false
18
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 8e530038abf9c45c793fcde74943dd3d
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,251 @@
1
+ using UnityEngine;
2
+ using UnityEditor;
3
+ using UnityEditor.PackageManager;
4
+ using System.IO;
5
+
6
+ namespace BACKND.Database.Editor
7
+ {
8
+ [InitializeOnLoad]
9
+ public static class PackageAssetInstaller
10
+ {
11
+ private const string PackageName = "com.backnd.database";
12
+ private const string SourceFolderName = "TheBackend~";
13
+ private const string TargetFolderName = "TheBackend";
14
+
15
+ private const string InstalledPrefsKey = "BACKND_Database_PluginsInstalled";
16
+ private const string SkippedPrefsKey = "BACKND_Database_PluginsSkipped";
17
+
18
+ static PackageAssetInstaller()
19
+ {
20
+ EditorApplication.delayCall += TryInstallAssets;
21
+ }
22
+
23
+ private static void TryInstallAssets()
24
+ {
25
+ // 이미 설치 완료 또는 스킵한 경우
26
+ if (EditorPrefs.GetBool(InstalledPrefsKey, false) ||
27
+ EditorPrefs.GetBool(SkippedPrefsKey, false))
28
+ {
29
+ return;
30
+ }
31
+
32
+ string targetPath = Path.Combine("Assets", TargetFolderName);
33
+
34
+ // 이미 Assets/TheBackend 폴더가 존재하면 설치 완료로 처리
35
+ // 핵심 파일들이 모두 존재하는지 확인
36
+ if (IsAlreadyInstalled(targetPath))
37
+ {
38
+ EditorPrefs.SetBool(InstalledPrefsKey, true);
39
+ return;
40
+ }
41
+
42
+ // 패키지 경로에서 소스 폴더 찾기
43
+ string sourcePath = FindSourcePath();
44
+
45
+ if (string.IsNullOrEmpty(sourcePath))
46
+ {
47
+ Debug.LogWarning("[BACKND Database] TheBackend~ 폴더를 찾을 수 없습니다.");
48
+ return;
49
+ }
50
+
51
+ // 사용자에게 설치 확인
52
+ int result = EditorUtility.DisplayDialogComplex(
53
+ "BACKND Database",
54
+ "BACKND SDK 플러그인을 설치하시겠습니까?\n\n" +
55
+ "이 플러그인은 BACKND Database 패키지 사용에 필요합니다.\n\n" +
56
+ $"설치 위치: Assets/{TargetFolderName}",
57
+ "설치",
58
+ "나중에",
59
+ "다시 묻지 않기"
60
+ );
61
+
62
+ switch (result)
63
+ {
64
+ case 0: // 설치
65
+ InstallAssets(sourcePath, targetPath);
66
+ break;
67
+ case 1: // 나중에
68
+ // 다음 에디터 실행 시 다시 물음
69
+ break;
70
+ case 2: // 다시 묻지 않기
71
+ EditorPrefs.SetBool(SkippedPrefsKey, true);
72
+ break;
73
+ }
74
+ }
75
+
76
+ private static bool IsAlreadyInstalled(string targetPath)
77
+ {
78
+ if (!Directory.Exists(targetPath))
79
+ return false;
80
+
81
+ string pluginsPath = Path.Combine(targetPath, "Plugins");
82
+ if (!Directory.Exists(pluginsPath))
83
+ return false;
84
+
85
+ // 핵심 파일들 확인
86
+ string[] requiredFiles = new string[]
87
+ {
88
+ Path.Combine(pluginsPath, "Backend.dll"),
89
+ Path.Combine(pluginsPath, "LitJSON.dll"),
90
+ Path.Combine(pluginsPath, "Android", "Backend.aar"),
91
+ Path.Combine(pluginsPath, "Editor", "TheBackendSettingEditor.dll"),
92
+ Path.Combine(pluginsPath, "Settings", "TheBackendSettings.dll")
93
+ };
94
+
95
+ foreach (string file in requiredFiles)
96
+ {
97
+ if (!File.Exists(file))
98
+ return false;
99
+ }
100
+
101
+ return true;
102
+ }
103
+
104
+ private static string FindSourcePath()
105
+ {
106
+ // 1. PackageInfo API를 사용하여 패키지 경로 찾기 (npm 패키지로 설치된 경우)
107
+ // Unity 공식 권장 방식: PackageInfo.FindForPackageName() + resolvedPath
108
+ var packageInfo = UnityEditor.PackageManager.PackageInfo.FindForPackageName(PackageName);
109
+ if (packageInfo != null)
110
+ {
111
+ // resolvedPath = 실제 디스크 경로 (예: Library/PackageCache/com.backnd.database@0.0.1)
112
+ string packageSourcePath = Path.Combine(packageInfo.resolvedPath, SourceFolderName);
113
+ if (Directory.Exists(packageSourcePath))
114
+ {
115
+ return packageSourcePath;
116
+ }
117
+ }
118
+
119
+ // 2. Assets 폴더에서 찾기 (개발 중인 경우)
120
+ string assetsSourcePath = Path.Combine("Assets", "BACKND", "Database", SourceFolderName);
121
+ if (Directory.Exists(assetsSourcePath))
122
+ {
123
+ return Path.GetFullPath(assetsSourcePath);
124
+ }
125
+
126
+ return null;
127
+ }
128
+
129
+ private static void InstallAssets(string sourcePath, string targetPath)
130
+ {
131
+ try
132
+ {
133
+ EditorUtility.DisplayProgressBar("BACKND Database", "플러그인 설치 중...", 0f);
134
+
135
+ // 대상 폴더 생성
136
+ if (!Directory.Exists(targetPath))
137
+ {
138
+ Directory.CreateDirectory(targetPath);
139
+ }
140
+
141
+ // 재귀적으로 복사
142
+ CopyDirectory(sourcePath, targetPath);
143
+
144
+ EditorUtility.DisplayProgressBar("BACKND Database", "에셋 데이터베이스 갱신 중...", 0.9f);
145
+
146
+ AssetDatabase.Refresh();
147
+
148
+ EditorPrefs.SetBool(InstalledPrefsKey, true);
149
+
150
+ EditorUtility.ClearProgressBar();
151
+
152
+ EditorUtility.DisplayDialog(
153
+ "BACKND Database",
154
+ "플러그인 설치가 완료되었습니다!\n\n" +
155
+ $"설치 위치: {targetPath}",
156
+ "확인"
157
+ );
158
+
159
+ Debug.Log($"[BACKND Database] 플러그인이 설치되었습니다: {targetPath}");
160
+ }
161
+ catch (System.Exception e)
162
+ {
163
+ EditorUtility.ClearProgressBar();
164
+ Debug.LogError($"[BACKND Database] 플러그인 설치 실패: {e.Message}");
165
+
166
+ EditorUtility.DisplayDialog(
167
+ "BACKND Database",
168
+ $"플러그인 설치 중 오류가 발생했습니다.\n\n{e.Message}",
169
+ "확인"
170
+ );
171
+ }
172
+ }
173
+
174
+ private static void CopyDirectory(string sourceDir, string targetDir)
175
+ {
176
+ var dir = new DirectoryInfo(sourceDir);
177
+
178
+ // 하위 폴더 복사
179
+ foreach (var subDir in dir.GetDirectories())
180
+ {
181
+ // 숨김 폴더 제외
182
+ if (subDir.Name.StartsWith("."))
183
+ continue;
184
+
185
+ string targetSubDir = Path.Combine(targetDir, subDir.Name);
186
+ Directory.CreateDirectory(targetSubDir);
187
+ CopyDirectory(subDir.FullName, targetSubDir);
188
+ }
189
+
190
+ // 파일 복사
191
+ foreach (var file in dir.GetFiles())
192
+ {
193
+ // 숨김 파일 및 .meta 파일 제외
194
+ if (file.Name.StartsWith(".") || file.Extension == ".meta")
195
+ continue;
196
+
197
+ string targetFile = Path.Combine(targetDir, file.Name);
198
+
199
+ // 이미 존재하는 파일은 덮어쓰지 않음
200
+ if (!File.Exists(targetFile))
201
+ {
202
+ file.CopyTo(targetFile);
203
+ }
204
+ }
205
+ }
206
+
207
+ // 메뉴에서 수동 설치
208
+ [MenuItem("BACKND/Database/Install SDK Plugins")]
209
+ private static void ManualInstall()
210
+ {
211
+ string sourcePath = FindSourcePath();
212
+
213
+ if (string.IsNullOrEmpty(sourcePath))
214
+ {
215
+ EditorUtility.DisplayDialog(
216
+ "BACKND Database",
217
+ "TheBackend~ 폴더를 찾을 수 없습니다.\n\n" +
218
+ "패키지가 올바르게 설치되었는지 확인해주세요.",
219
+ "확인"
220
+ );
221
+ return;
222
+ }
223
+
224
+ string targetPath = Path.Combine("Assets", TargetFolderName);
225
+
226
+ if (Directory.Exists(targetPath))
227
+ {
228
+ bool overwrite = EditorUtility.DisplayDialog(
229
+ "BACKND Database",
230
+ $"Assets/{TargetFolderName} 폴더가 이미 존재합니다.\n\n" +
231
+ "새로운 파일만 추가됩니다. (기존 파일 유지)",
232
+ "계속",
233
+ "취소"
234
+ );
235
+
236
+ if (!overwrite) return;
237
+ }
238
+
239
+ InstallAssets(sourcePath, targetPath);
240
+ }
241
+
242
+ // 설치 상태 초기화 (디버그용)
243
+ [MenuItem("BACKND/Database/Reset Install State")]
244
+ private static void ResetInstallState()
245
+ {
246
+ EditorPrefs.DeleteKey(InstalledPrefsKey);
247
+ EditorPrefs.DeleteKey(SkippedPrefsKey);
248
+ Debug.Log("[BACKND Database] 설치 상태가 초기화되었습니다.");
249
+ }
250
+ }
251
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 9d0d1b8c1176d4a11a9ccf1a41fc43a7
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/Editor.meta ADDED
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 8f8017847d2bc4923bc44207a68dc3cc
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,34 @@
1
+ using System;
2
+
3
+ namespace BACKND.Database.Exceptions
4
+ {
5
+ public class DatabaseException : Exception
6
+ {
7
+ public string Query { get; }
8
+ public string Operation { get; }
9
+ public string TableName { get; }
10
+
11
+ public DatabaseException(string message) : base(message)
12
+ {
13
+ }
14
+
15
+ public DatabaseException(string message, Exception innerException)
16
+ : base(message, innerException)
17
+ {
18
+ }
19
+
20
+ public DatabaseException(string message, string query, string operation = null, string tableName = null)
21
+ : base(message)
22
+ {
23
+ Query = query;
24
+ Operation = operation;
25
+ TableName = tableName;
26
+ }
27
+
28
+ public DatabaseException(string message, string query, Exception innerException)
29
+ : base(message, innerException)
30
+ {
31
+ Query = query;
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 121b234f8c7494950b7221d7cf294046
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 2b20b182b745e49b2a96d8853287184a
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant: