firebird-admin 2.2.0__tar.gz → 2.3.0__tar.gz

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 (310) hide show
  1. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/PKG-INFO +1 -1
  2. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/__init__.py +1 -1
  3. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/__main__.py +4 -0
  4. firebird_admin-2.3.0/fbadmin/admin_file.py +64 -0
  5. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/desktop.py +15 -1
  6. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/core.py +44 -4
  7. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/settings.py +7 -0
  8. firebird_admin-2.2.0/fbadmin/static/assets/DataView-I7qSFmAb.js → firebird_admin-2.3.0/fbadmin/static/assets/DataView-CmC4HZsO.js +1 -1
  9. firebird_admin-2.2.0/fbadmin/static/assets/Jobs-wTJyoaCt.js → firebird_admin-2.3.0/fbadmin/static/assets/Jobs-D215CNEt.js +1 -1
  10. firebird_admin-2.2.0/fbadmin/static/assets/Monitor-DXRRm-D_.js → firebird_admin-2.3.0/fbadmin/static/assets/Monitor-BrvIq16n.js +1 -1
  11. firebird_admin-2.3.0/fbadmin/static/assets/QueryTool-BHLnKty-.js +26 -0
  12. firebird_admin-2.2.0/fbadmin/static/assets/index-DRn3r74l.css → firebird_admin-2.3.0/fbadmin/static/assets/index-Bsdje2iR.css +1 -1
  13. firebird_admin-2.3.0/fbadmin/static/assets/index-C1cNciQ3.js +177 -0
  14. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/index.html +2 -2
  15. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/firebird_admin.egg-info/PKG-INFO +1 -1
  16. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/firebird_admin.egg-info/SOURCES.txt +9 -6
  17. firebird_admin-2.3.0/tests/test_admin_file.py +61 -0
  18. firebird_admin-2.3.0/tests/test_desktop_menu.py +33 -0
  19. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_notebook_runs.py +3 -1
  20. firebird_admin-2.2.0/fbadmin/static/assets/QueryTool-B-pMqsHe.js +0 -26
  21. firebird_admin-2.2.0/fbadmin/static/assets/index-BK8RZ2IB.js +0 -173
  22. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/README.md +0 -0
  23. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/ai/__init__.py +0 -0
  24. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/ai/providers.py +0 -0
  25. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/alerts/__init__.py +0 -0
  26. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/alerts/channels.py +0 -0
  27. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/alerts/checks.py +0 -0
  28. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/alerts/engine.py +0 -0
  29. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/alerts/store.py +0 -0
  30. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/anonymise.py +0 -0
  31. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/__init__.py +0 -0
  32. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/access.py +0 -0
  33. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/admin.py +0 -0
  34. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/ai.py +0 -0
  35. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/alerts.py +0 -0
  36. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/anonymise.py +0 -0
  37. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/audit_forwarding.py +0 -0
  38. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/auth.py +0 -0
  39. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/backup_keys.py +0 -0
  40. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/changes.py +0 -0
  41. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/checkup.py +0 -0
  42. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/client.py +0 -0
  43. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/comments.py +0 -0
  44. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/databases.py +0 -0
  45. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/datacompare.py +0 -0
  46. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/debug.py +0 -0
  47. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/deps.py +0 -0
  48. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/driver.py +0 -0
  49. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/embedded.py +0 -0
  50. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/events.py +0 -0
  51. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/fbsecurity.py +0 -0
  52. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/fleet.py +0 -0
  53. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/forecast.py +0 -0
  54. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/jobs.py +0 -0
  55. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/kubernetes.py +0 -0
  56. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/library.py +0 -0
  57. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/links.py +0 -0
  58. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/maintenance.py +0 -0
  59. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/metrics.py +0 -0
  60. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/migrations.py +0 -0
  61. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/monitoring.py +0 -0
  62. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/notebooks.py +0 -0
  63. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/object_dialogs.py +0 -0
  64. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/overview.py +0 -0
  65. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/query.py +0 -0
  66. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/querybuilder.py +0 -0
  67. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/regressions.py +0 -0
  68. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/replication.py +0 -0
  69. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/replication_setup.py +0 -0
  70. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/schedules.py +0 -0
  71. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/schema.py +0 -0
  72. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/schema_history.py +0 -0
  73. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/servers.py +0 -0
  74. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/storage.py +0 -0
  75. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/timeline.py +0 -0
  76. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/trace.py +0 -0
  77. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/trace_capture.py +0 -0
  78. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/upgrade.py +0 -0
  79. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/version.py +0 -0
  80. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/api/windows.py +0 -0
  81. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/app.py +0 -0
  82. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/changes.py +0 -0
  83. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/__init__.py +0 -0
  84. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/backup.py +0 -0
  85. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/common.py +0 -0
  86. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/crypt.py +0 -0
  87. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/migrate.py +0 -0
  88. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/misc.py +0 -0
  89. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/registry.py +0 -0
  90. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/remote.py +0 -0
  91. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/cli/schema.py +0 -0
  92. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/comments.py +0 -0
  93. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/config.py +0 -0
  94. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/configfile.py +0 -0
  95. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/connections.py +0 -0
  96. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/connstate.py +0 -0
  97. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/datacompare/__init__.py +0 -0
  98. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/datacompare/engine.py +0 -0
  99. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/datacompare/literals.py +0 -0
  100. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/debug/__init__.py +0 -0
  101. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/debug/psql.py +0 -0
  102. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/debug/runner.py +0 -0
  103. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/debug/store.py +0 -0
  104. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/digest.py +0 -0
  105. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/driver_patches.py +0 -0
  106. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/drivers.py +0 -0
  107. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/embedded.py +0 -0
  108. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/events/__init__.py +0 -0
  109. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/events/monitor.py +0 -0
  110. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/events/scan.py +0 -0
  111. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/events/wire.py +0 -0
  112. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/fb4types.py +0 -0
  113. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/fleet.py +0 -0
  114. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/jobs.py +0 -0
  115. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/kube/__init__.py +0 -0
  116. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/kube/client.py +0 -0
  117. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/kube/operator.py +0 -0
  118. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/library.py +0 -0
  119. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/limits.py +0 -0
  120. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/links.py +0 -0
  121. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/logsetup.py +0 -0
  122. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/__init__.py +0 -0
  123. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/archive.py +0 -0
  124. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/backupcrypt.py +0 -0
  125. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/cron.py +0 -0
  126. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/drift.py +0 -0
  127. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/drill.py +0 -0
  128. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/gstat.py +0 -0
  129. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/ops.py +0 -0
  130. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/scheduler.py +0 -0
  131. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/svc.py +0 -0
  132. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/trace.py +0 -0
  133. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/maintenance/verify.py +0 -0
  134. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/metadata/__init__.py +0 -0
  135. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/metadata/catalog.py +0 -0
  136. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/metadata/catalog_extras.py +0 -0
  137. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/metadata/ddlgen.py +0 -0
  138. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/metadata/designer.py +0 -0
  139. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/metadata/types.py +0 -0
  140. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/middleware.py +0 -0
  141. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/migrations.py +0 -0
  142. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/__init__.py +0 -0
  143. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/advisor.py +0 -0
  144. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/checkup.py +0 -0
  145. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/checkup_ai.py +0 -0
  146. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/checkup_schedule.py +0 -0
  147. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/forecast.py +0 -0
  148. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/history.py +0 -0
  149. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/journal.py +0 -0
  150. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/metrics.py +0 -0
  151. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/overview.py +0 -0
  152. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/probes.py +0 -0
  153. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/profiler.py +0 -0
  154. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/regressions.py +0 -0
  155. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/repl_setup.py +0 -0
  156. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/replication.py +0 -0
  157. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/trace_capture.py +0 -0
  158. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/trace_errors.py +0 -0
  159. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/monitoring/unused_indices.py +0 -0
  160. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/native.py +0 -0
  161. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/notebook_runs.py +0 -0
  162. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/notebooks.py +0 -0
  163. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/plugins.py +0 -0
  164. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/preconfig.py +0 -0
  165. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/prepared.py +0 -0
  166. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/query.py +0 -0
  167. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/__init__.py +0 -0
  168. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/copydata.py +0 -0
  169. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/dataio.py +0 -0
  170. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/diff.py +0 -0
  171. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/extract.py +0 -0
  172. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/generator.py +0 -0
  173. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/model.py +0 -0
  174. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/report.py +0 -0
  175. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema/search.py +0 -0
  176. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schema_ctx.py +0 -0
  177. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schemahistory/__init__.py +0 -0
  178. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schemahistory/gitrepo.py +0 -0
  179. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/schemahistory/layout.py +0 -0
  180. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/__init__.py +0 -0
  181. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/access.py +0 -0
  182. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/audit.py +0 -0
  183. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/crypto.py +0 -0
  184. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/db.py +0 -0
  185. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/errors.py +0 -0
  186. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/fbservices.py +0 -0
  187. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/fbsql.py +0 -0
  188. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/forward.py +0 -0
  189. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/ldap.py +0 -0
  190. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/mfa.py +0 -0
  191. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/middleware.py +0 -0
  192. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/oidc.py +0 -0
  193. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/proxy.py +0 -0
  194. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/readonly.py +0 -0
  195. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/runas.py +0 -0
  196. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/servers.py +0 -0
  197. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/sessions.py +0 -0
  198. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/tokens.py +0 -0
  199. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/security/totp.py +0 -0
  200. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/serialize.py +0 -0
  201. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/sqlsplit.py +0 -0
  202. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/assets/codemirror-CQtTaafu.js +0 -0
  203. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/assets/react-D1VdbdIl.js +0 -0
  204. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/assets/sql-formatter-BMeiBS2F.js +0 -0
  205. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/icons/apple-touch-icon.png +0 -0
  206. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/icons/icon-192.png +0 -0
  207. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/icons/icon-512.png +0 -0
  208. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/icons/icon.svg +0 -0
  209. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/static/manifest.webmanifest +0 -0
  210. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/storage/__init__.py +0 -0
  211. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/storage/azure.py +0 -0
  212. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/storage/base.py +0 -0
  213. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/storage/gcs.py +0 -0
  214. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/storage/s3.py +0 -0
  215. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/storage/targets.py +0 -0
  216. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/store.py +0 -0
  217. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/timeline.py +0 -0
  218. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/updater.py +0 -0
  219. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/upgrade/__init__.py +0 -0
  220. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/upgrade/checks.py +0 -0
  221. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/upgrade/keywords.py +0 -0
  222. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/upgrade/keywords_data.py +0 -0
  223. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/upgrade/plan.py +0 -0
  224. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/upgrade/trial.py +0 -0
  225. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/uploads.py +0 -0
  226. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/fbadmin/windows.py +0 -0
  227. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/firebird_admin.egg-info/dependency_links.txt +0 -0
  228. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/firebird_admin.egg-info/entry_points.txt +0 -0
  229. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/firebird_admin.egg-info/requires.txt +0 -0
  230. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/firebird_admin.egg-info/top_level.txt +0 -0
  231. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/pyproject.toml +0 -0
  232. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/setup.cfg +0 -0
  233. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_access.py +0 -0
  234. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_access_fb.py +0 -0
  235. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_advisor_parse.py +0 -0
  236. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_ai.py +0 -0
  237. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_alerts.py +0 -0
  238. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_anonymise.py +0 -0
  239. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_api.py +0 -0
  240. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_audit_forwarding.py +0 -0
  241. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_backup_encryption_drills.py +0 -0
  242. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_changes.py +0 -0
  243. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_checkup.py +0 -0
  244. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_checkup_ai.py +0 -0
  245. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_checkup_schedule.py +0 -0
  246. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_cli.py +0 -0
  247. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_cli_remote.py +0 -0
  248. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_comments.py +0 -0
  249. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_configfile.py +0 -0
  250. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_connstate.py +0 -0
  251. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_datacompare.py +0 -0
  252. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_ddl_property.py +0 -0
  253. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_debug.py +0 -0
  254. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_debug_psql.py +0 -0
  255. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_digest.py +0 -0
  256. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_drill_storage_real.py +0 -0
  257. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_driver_auto.py +0 -0
  258. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_driver_equivalence.py +0 -0
  259. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_driver_patches.py +0 -0
  260. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_embedded.py +0 -0
  261. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_encryption_plugin.py +0 -0
  262. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_engineering.py +0 -0
  263. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_events.py +0 -0
  264. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_fb4types.py +0 -0
  265. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_firebird_qa.py +0 -0
  266. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_fleet.py +0 -0
  267. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_forecast.py +0 -0
  268. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_jobs_cancel.py +0 -0
  269. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_kubernetes.py +0 -0
  270. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_large_schema.py +0 -0
  271. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_ldap_real.py +0 -0
  272. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_library.py +0 -0
  273. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_links.py +0 -0
  274. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_maintenance.py +0 -0
  275. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_maintenance_units.py +0 -0
  276. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_migrations.py +0 -0
  277. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_monitoring.py +0 -0
  278. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_native_driver.py +0 -0
  279. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_notebooks.py +0 -0
  280. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_objects_03.py +0 -0
  281. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_oidc_real.py +0 -0
  282. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_overview.py +0 -0
  283. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_plugins.py +0 -0
  284. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_preconfig.py +0 -0
  285. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_prepared.py +0 -0
  286. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_query_regressions.py +0 -0
  287. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_query_tool.py +0 -0
  288. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_querybuilder.py +0 -0
  289. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_replication.py +0 -0
  290. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_replication_setup.py +0 -0
  291. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_schema_drift.py +0 -0
  292. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_schema_history.py +0 -0
  293. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_schema_tools.py +0 -0
  294. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_schemas_fb6.py +0 -0
  295. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_security.py +0 -0
  296. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_security_fb.py +0 -0
  297. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_sqlsplit.py +0 -0
  298. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_sqlsplit_fuzz.py +0 -0
  299. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_startup_race.py +0 -0
  300. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_storage.py +0 -0
  301. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_storage_real.py +0 -0
  302. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_timeline.py +0 -0
  303. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_trace_capture.py +0 -0
  304. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_trace_errors.py +0 -0
  305. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_types.py +0 -0
  306. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_unused_indices.py +0 -0
  307. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_updater.py +0 -0
  308. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_upgrade.py +0 -0
  309. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_uploads.py +0 -0
  310. {firebird_admin-2.2.0 → firebird_admin-2.3.0}/tests/test_windows.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: firebird-admin
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: A pgAdmin-style web administration and development tool for Firebird SQL
5
5
  Author: fbadmin contributors
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  """fbadmin - a pgAdmin-style administration tool for Firebird SQL."""
2
2
 
3
- __version__ = "2.2.0"
3
+ __version__ = "2.3.0"
4
4
 
5
5
  from . import driver_patches as _driver_patches # noqa: E402
6
6
 
@@ -33,6 +33,10 @@ def _remote_command(argv: list[str], commands) -> bool:
33
33
 
34
34
  def main(argv: list[str] | None = None) -> None:
35
35
  argv = list(sys.argv[1:] if argv is None else argv)
36
+ if argv and argv[0] == "write-admin-file": # internal: the Windows server MSI (fbadmin/admin_file.py)
37
+ from .admin_file import main as write_admin_file
38
+
39
+ sys.exit(write_admin_file())
36
40
  from .cli import COMMANDS
37
41
 
38
42
  if argv and (argv[0] in COMMANDS or _remote_command(argv, COMMANDS)):
@@ -0,0 +1,64 @@
1
+ """``fbadmin-server write-admin-file PATH --user=NAME --email=EMAIL --password=PASSWORD`` (internal, issue #11).
2
+
3
+ The Windows server MSI runs this as a custom action whose command line it hides in its log, to write the one-time
4
+ administrator file (``FBADMIN_ADMIN_FILE``, read and deleted by fbadmin at its first start in server mode). MSI's
5
+ own IniFile action would log the password, and MSI cannot escape a value for a command line, so the options are
6
+ read from the raw command line: everything after ``--password=`` is the password, quotes, spaces and backslashes
7
+ included.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import sys
13
+ from pathlib import Path
14
+
15
+ MARKERS = (" --user=", " --email=", " --password=")
16
+
17
+
18
+ def _raw_command_line() -> str:
19
+ if sys.platform == "win32":
20
+ import ctypes
21
+
22
+ get = ctypes.windll.kernel32.GetCommandLineW # type: ignore[attr-defined]
23
+ get.restype = ctypes.c_wchar_p
24
+ return get()
25
+ return " ".join(sys.argv)
26
+
27
+
28
+ def parse(raw: str) -> tuple[str, dict[str, str]]:
29
+ """The file path and the values, from ``... write-admin-file "PATH" --user=... --email=... --password=...``."""
30
+ rest = raw.split("write-admin-file", 1)[1]
31
+ found = sorted((rest.find(m), m) for m in MARKERS if rest.find(m) >= 0)
32
+ if not found or found[-1][1] != " --password=":
33
+ raise ValueError("--password= must come last")
34
+ path = rest[: found[0][0]].strip().strip('"')
35
+ values: dict[str, str] = {}
36
+ for i, (pos, marker) in enumerate(found):
37
+ end = found[i + 1][0] if i + 1 < len(found) else len(rest)
38
+ value = rest[pos + len(marker): end]
39
+ values[marker.strip(" -=")] = value if marker == " --password=" else value.strip().strip('"')
40
+ values["password"] = values["password"].rstrip("\r\n")
41
+ if not path:
42
+ raise ValueError("no file given")
43
+ return path, values
44
+
45
+
46
+ def write(path: Path, values: dict[str, str]) -> None:
47
+ lines = ["[admin]"]
48
+ for key, out in (("user", "username"), ("email", "email"), ("password", "password")):
49
+ if values.get(key):
50
+ lines.append(f'{out}="{values[key]}"')
51
+ path.parent.mkdir(parents=True, exist_ok=True)
52
+ path.write_text("\n".join(lines) + "\n", "utf-8")
53
+
54
+
55
+ def main(raw: str | None = None) -> int:
56
+ try:
57
+ path, values = parse(raw if raw is not None else _raw_command_line())
58
+ except (ValueError, IndexError) as exc:
59
+ print(f"write-admin-file: {exc}", file=sys.stderr)
60
+ return 2
61
+ if not values.get("password"):
62
+ return 0 # nothing to write
63
+ write(Path(path), values)
64
+ return 0
@@ -101,6 +101,20 @@ class DesktopApi:
101
101
  return result if isinstance(result, str) else result[0]
102
102
 
103
103
 
104
+ def _webview_start_options(webview) -> dict:
105
+ """The native right-click menu (Cut, Copy, Paste in the editor and in fields, issue #16): pywebview shows it
106
+ only in its debug mode, which here keeps the developer tools closed and pywebview's log quiet.
107
+ FBADMIN_DESKTOP_CONTEXT_MENU=0 turns it off (pywebview's default: no menu at all)."""
108
+ if os.environ.get("FBADMIN_DESKTOP_CONTEXT_MENU", "1").strip().lower() in ("0", "false", "no", "off"):
109
+ return {}
110
+ try:
111
+ webview.settings["OPEN_DEVTOOLS_IN_DEBUG"] = False
112
+ except Exception: # noqa: BLE001 - an older pywebview without the setting would open the tools: keep it off
113
+ return {}
114
+ os.environ.setdefault("PYWEBVIEW_LOG", "warning")
115
+ return {"debug": True}
116
+
117
+
104
118
  def _handle_sigterm(webview) -> None:
105
119
  """Quit cleanly on SIGTERM (logout, ``kill``): close the window / leave the wait loop.
106
120
 
@@ -148,7 +162,7 @@ def main(argv: list[str] | None = None) -> int:
148
162
  try:
149
163
  webview.create_window(f"fbadmin {__version__}", srv.url, width=1400, height=900,
150
164
  min_size=(900, 600), js_api=DesktopApi(webview))
151
- webview.start() # blocks until the window is closed
165
+ webview.start(**_webview_start_options(webview)) # blocks until the window is closed
152
166
  except Exception as exc: # noqa: BLE001 - no GUI backend (e.g. headless Linux)
153
167
  log.warning("cannot open a native window (%s); using the web browser", exc)
154
168
  else:
@@ -3,9 +3,11 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
+ import logging
6
7
  import os
7
8
  import shutil
8
9
  import time
10
+ from pathlib import Path
9
11
  from typing import Any
10
12
 
11
13
  from . import ldap as ldap_backend
@@ -28,6 +30,26 @@ from .settings import SecuritySettings
28
30
  MIN_PASSWORD = 8
29
31
  INTERNAL = "internal"
30
32
 
33
+ log = logging.getLogger("fbadmin.security")
34
+
35
+
36
+ def read_admin_file(path: Path) -> dict[str, str]:
37
+ """``username=``, ``email=`` and ``password=`` lines (``[section]`` headers and ``#`` comments are skipped).
38
+ A value in double quotes is taken literally between the first and the last quote: a password may contain
39
+ quotes, backslashes or ``=``."""
40
+ out: dict[str, str] = {}
41
+ for line in path.read_text("utf-8-sig").splitlines():
42
+ line = line.strip()
43
+ if not line or line.startswith(("#", ";", "[")) or "=" not in line:
44
+ continue
45
+ key, value = line.split("=", 1)
46
+ key, value = key.strip().lower(), value.strip()
47
+ if len(value) >= 2 and value[0] == value[-1] == '"':
48
+ value = value[1:-1]
49
+ if key in ("username", "email", "password"):
50
+ out[key] = value
51
+ return out
52
+
31
53
 
32
54
  class Security:
33
55
  def __init__(self, settings: SecuritySettings, state: Any):
@@ -64,11 +86,29 @@ class Security:
64
86
  return self.server_mode and self.db.user_count() == 0
65
87
 
66
88
  def bootstrap(self) -> None:
67
- """Create the initial admin from FBADMIN_ADMIN_EMAIL / FBADMIN_ADMIN_PASSWORD. Safe when several
68
- processes (workers, replicas on one volume) start at once: only the first one creates it."""
89
+ """Create the initial admin from FBADMIN_ADMIN_EMAIL / FBADMIN_ADMIN_PASSWORD, or from FBADMIN_ADMIN_FILE.
90
+ Safe when several processes (workers, replicas on one volume) start at once: only the first one creates it."""
69
91
  s = self.settings
70
- if self.server_mode and s.admin_username and s.admin_password and self.db.user_count() == 0:
71
- self.create_first_admin(s.admin_username, email=s.admin_email or None, password=s.admin_password)
92
+ username, email, password = s.admin_username, s.admin_email, s.admin_password
93
+ file = Path(s.admin_file) if s.admin_file else None
94
+ if file is not None and file.is_file() and self.server_mode:
95
+ values = read_admin_file(file)
96
+ password = values.get("password") or password
97
+ email = values.get("email") or email
98
+ username = values.get("username") or email or username or ("admin" if password else "")
99
+ if self.server_mode and username and password and self.db.user_count() == 0:
100
+ try:
101
+ self.create_first_admin(username, email=email or None, password=password)
102
+ log.info("created the administrator %r", username)
103
+ except SecurityError as exc:
104
+ log.error("the initial administrator was not created: %s", exc.detail)
105
+ # the file holds a password: once an account exists it has done its job
106
+ if file is not None and file.is_file() and self.server_mode and self.db.user_count() > 0:
107
+ try:
108
+ file.unlink()
109
+ log.info("deleted %s (the initial administrator exists)", file)
110
+ except OSError as exc:
111
+ log.warning("could not delete %s: %s", file, exc)
72
112
 
73
113
  def create_first_admin(self, username: str, *, email: str | None, password: str) -> dict[str, Any] | None:
74
114
  """The first administrator (bootstrap or the setup page); None if a user exists already."""
@@ -129,6 +129,9 @@ class SecuritySettings:
129
129
  admin_username: str = ""
130
130
  admin_email: str = ""
131
131
  admin_password: str = ""
132
+ # a one-time file with username= / email= / password= lines (the Windows server MSI writes it); deleted once
133
+ # an account exists
134
+ admin_file: str = ""
132
135
  auto_create_users: bool = True
133
136
  login_rate: tuple[int, int] = (5, 300)
134
137
  api_rate: tuple[int, int] = (1200, 60)
@@ -197,6 +200,10 @@ def load(data_dir: Path) -> SecuritySettings:
197
200
  s.admin_email = str(_env("ADMIN_EMAIL", file_cfg) or "")
198
201
  s.admin_username = str(_env("ADMIN_USERNAME", file_cfg) or s.admin_email or "")
199
202
  s.admin_password = str(_env("ADMIN_PASSWORD", file_cfg) or "")
203
+ admin_file = str(_env("ADMIN_FILE", file_cfg) or "")
204
+ if admin_file and not Path(admin_file).is_absolute():
205
+ admin_file = str(data_dir / admin_file)
206
+ s.admin_file = admin_file
200
207
  s.auto_create_users = _bool(_env("AUTO_CREATE_USERS", file_cfg), True)
201
208
  s.login_rate = _rate(_env("LOGIN_RATE", file_cfg), s.login_rate)
202
209
  s.api_rate = _rate(_env("RATE_LIMIT", file_cfg), s.api_rate)
@@ -1 +1 @@
1
- import{r as u,j as e}from"./react-D1VdbdIl.js";import{u as ae,D as le,t as i,E as ie,j as oe,x as ce,F as re,o as de,p as ue,G as me,H as $,q as he,J as xe,b as H,f as G,M as be}from"./index-BK8RZ2IB.js";import"./codemirror-CQtTaafu.js";import"./sql-formatter-BMeiBS2F.js";const fe=/INT|NUMERIC|DOUBLE|FLOAT|DECFLOAT/,R="FBADMIN$DB_KEY";function Ce(a){var z;const D=ae(),[c,E]=u.useState(null),[d,p]=u.useState([]),[I,j]=u.useState(null),[m,v]=u.useState(!1),[h,y]=u.useState(100),[x,O]=u.useState(0),[_,M]=u.useState(""),[U,Y]=u.useState(""),[K,J]=u.useState(!!a.showFilter),[b,Q]=u.useState(null),[T,g]=u.useState(null),[B,q]=u.useState(null),L=a.otype==="tables",[N,W]=u.useState(null),w=async(t=x)=>{v(!0),j(null);try{const s=await H.tableData(a.serverId,a.dbId,a.name,{limit:h,offset:t,..._?{where:_}:{},...b?{order_by:b.col,descending:b.desc}:{}});E(s),p(s.rows.map(r=>({values:[...r],orig:r,status:"clean"}))),O(t),q(null),g(null)}catch(s){j(G(s))}finally{v(!1)}};u.useEffect(()=>{w(0)},[h,_,b]);const C=(c==null?void 0:c.columns)??[],X=c?c.primary_key.length?c.primary_key:[R]:[],A=t=>c==null?void 0:c.column_meta.find(s=>s.name===t),k=C.map((t,s)=>({c:t,i:s})).filter(({c:t})=>t.name!==R),V=d.some(t=>t.status!=="clean"),F=(t,s,r)=>{p(n=>n.map((l,o)=>{if(o!==t)return l;const S=[...l.values];return S[s]=r,{...l,values:S,status:l.status==="new"?"new":"changed"}}))},Z=async()=>{if(!c)return;const t=n=>C.findIndex(l=>l.name===n),s=n=>Object.fromEntries(X.map(l=>[l,n.orig[t(l)]])),r={deletes:d.filter(n=>n.status==="deleted"&&n.orig).map(n=>({key:s(n)})),updates:d.filter(n=>n.status==="changed").map(n=>({key:s(n),values:Object.fromEntries(C.map((l,o)=>[l.name,n.values[o]]).filter(([l],o)=>l!==R&&n.values[o]!==n.orig[o]))})),inserts:d.filter(n=>n.status==="new").map(n=>({values:Object.fromEntries(C.map((l,o)=>[l.name,n.values[o]]).filter(([l,o])=>l!==R&&o!==void 0))}))};try{const n=await H.saveTableData(a.serverId,a.dbId,a.name,r);D.toast(i("Saved: {statements} statement(s), {affected} row(s)",{statements:n.statements,affected:n.affected})),w(x)}catch(n){D.toast(G(n),"error")}},ee=()=>{const t=C.map(()=>{});p(r=>[...r,{values:t,status:"new"}]);const s=k.find(({c:r})=>{var n,l;return!((n=A(r.name))!=null&&n.computed)&&!((l=A(r.name))!=null&&l.identity)});s&&g([d.length,s.i])};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{className:"toolbar",children:[e.jsx("button",{className:"btn icon",title:i("Refresh"),onClick:()=>w(x),children:e.jsx(le,{})}),e.jsx("button",{className:"btn icon"+(K?" on":""),title:i("Filter"),onClick:()=>J(!K),children:e.jsx(ie,{})}),L&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sep"}),e.jsxs("button",{className:"btn",onClick:ee,children:[e.jsx(oe,{})," ",i("Row")]}),e.jsxs("button",{className:"btn",disabled:B===null,onClick:()=>{B!==null&&p(t=>t.flatMap((s,r)=>r!==B?[s]:s.status==="new"?[]:[{...s,status:"deleted"}]))},children:[e.jsx(ce,{})," ",i("Delete")]}),e.jsxs("button",{className:"btn primary",disabled:!V,onClick:Z,children:[e.jsx(re,{})," ",i("Save")]}),e.jsx("button",{className:"btn",disabled:!V,onClick:()=>w(x),children:i("Discard")})]}),e.jsx("span",{className:"sep"}),e.jsxs("button",{className:"btn",disabled:x===0||m,onClick:()=>w(Math.max(0,x-h)),children:["‹ ",i("Prev")]}),e.jsx("span",{className:"muted",children:i("rows {from}–{to}",{from:d.length?x+1:0,to:x+((c==null?void 0:c.rows.length)??0)})}),e.jsxs("button",{className:"btn",disabled:!(c!=null&&c.has_more)||m,onClick:()=>w(x+h),children:[i("Next")," ›"]}),e.jsx("select",{className:"text",value:h,onChange:t=>y(Number(t.target.value)),children:[50,100,500,1e3,5e3].map(t=>e.jsx("option",{value:t,children:i("{count} / page",{count:t})},t))}),e.jsx("span",{className:"grow"}),c&&e.jsxs("button",{className:"btn small",onClick:()=>ue(`${a.name}.csv`,me(k.map(({c:t})=>t),d.map(t=>k.map(({i:s})=>t.values[s])))),children:[e.jsx(de,{size:13})," CSV"]})]}),K&&e.jsxs("div",{className:"toolbar",children:[e.jsx("span",{className:"muted",children:"WHERE"}),e.jsx("input",{className:"text mono",style:{flex:1},value:U,placeholder:i("e.g. NAME LIKE 'A%' AND ID > 10"),onChange:t=>Y(t.target.value),onKeyDown:t=>t.key==="Enter"&&M(U),autoFocus:!0}),e.jsx("button",{className:"btn",onClick:()=>M(U),children:i("Apply")}),e.jsx("button",{className:"btn",onClick:()=>{Y(""),M("")},children:i("Clear")})]}),I&&e.jsx("div",{className:"pad err",style:{whiteSpace:"pre-wrap"},children:I}),!L&&e.jsx("div",{className:"pad muted",style:{padding:"4px 10px"},children:a.otype==="views"?i("Read-only (view)."):i("Read-only (system table).")}),L&&c&&!c.primary_key.length&&e.jsx("div",{className:"pad warn",style:{padding:"4px 10px"},children:i("No primary key: rows are identified by RDB$DB_KEY (valid only within this session's view of the data).")}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[e.jsxs("table",{className:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"rn",children:"#"}),k.map(({c:t})=>{const s=A(t.name);return e.jsxs("th",{style:{cursor:"pointer"},onClick:()=>Q((b==null?void 0:b.col)===t.name?b.desc?null:{col:t.name,desc:!0}:{col:t.name,desc:!1}),children:[s!=null&&s.primary_key?"🔑 ":"",t.name," ",(b==null?void 0:b.col)===t.name?b.desc?"▼":"▲":"",e.jsxs("span",{className:"ty",children:[((s==null?void 0:s.data_type)??t.type).toLowerCase(),s!=null&&s.not_null?" not null":""]})]},t.name)})]})}),e.jsx("tbody",{children:d.map((t,s)=>e.jsxs("tr",{className:t.status==="clean"?"":t.status,onClick:()=>q(s),children:[e.jsx("td",{className:"rn",style:B===s?{color:"var(--accent)",fontWeight:700}:void 0,children:x+s+1}),k.map(({c:r,i:n})=>{const l=t.values[n],o=A(r.name),S=!L||t.status==="deleted"||!!(o!=null&&o.computed)||(o==null?void 0:o.identity)==="ALWAYS",te=T&&T[0]===s&&T[1]===n,se=t.orig&&t.values[n]!==t.orig[n],P=l===null,ne=[P?"null":"",fe.test(r.type)?"num":"",se?"dirty":""].join(" ");return te?e.jsx("td",{className:"sel",children:e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("input",{autoFocus:!0,defaultValue:l==null?"":$(l),onKeyDown:f=>{f.key==="Enter"&&(F(s,n,f.target.value),g(null)),f.key==="Escape"&&g(null)},onBlur:f=>{f.target.value!==(l==null?"":$(l))&&F(s,n,f.target.value),g(null)}}),e.jsx("button",{className:"btn small",title:i("Set NULL"),onMouseDown:f=>{f.preventDefault(),F(s,n,null),g(null)},children:"∅"}),e.jsx("button",{className:"btn small",title:i("Edit in a larger editor / upload a file"),onMouseDown:f=>{f.preventDefault(),g(null),W({ri:s,ci:n,name:r.name,blob:(o==null?void 0:o.field_type)===261,text:(o==null?void 0:o.field_sub_type)===1})},children:"…"})]})},r.name):e.jsx("td",{className:ne,onDoubleClick:()=>!S&&g([s,n]),title:S?void 0:i("Double-click to edit"),children:l===void 0?e.jsx("span",{className:"muted",children:o!=null&&o.identity||o!=null&&o.default?"default":""}):P?he().nullDisplay:ye(l)?e.jsx("span",{className:"muted",children:je(l)}):xe(l,r.type).slice(0,500)},r.name)})]},s))})]}),c&&d.length===0&&e.jsx("div",{className:"pad muted",children:i("No rows.")})]}),c&&e.jsx("div",{className:"status",children:e.jsx("span",{className:"mono",title:c.sql,children:c.sql.length>160?c.sql.slice(0,160)+"…":c.sql})}),N&&e.jsx(ve,{title:N.name,value:(z=d[N.ri])==null?void 0:z.values[N.ci],binary:N.blob&&!N.text,onClose:()=>W(null),onSave:t=>{F(N.ri,N.ci,t),W(null)}})]})}const ye=a=>typeof a=="string"&&(/^0x[0-9A-F]+$/.test(a)||a.startsWith("<BINARY")),je=a=>a.startsWith("<BINARY")?a.split(">")[0]+">":`<${(a.length-2)/2} bytes>`;function ve(a){const D=a.value===null||a.value===void 0||typeof a.value=="object"?"":$(a.value),[c,E]=u.useState(a.binary?"":D),[d,p]=u.useState(null),I=()=>{const m=document.createElement("input");m.type="file",m.onchange=async()=>{var x;const v=(x=m.files)==null?void 0:x[0];if(!v)return;const h=new Uint8Array(await v.arrayBuffer());let y="";for(const O of h)y+=O.toString(16).padStart(2,"0");a.binary?p({name:v.name,hex:y,size:h.length}):E(new TextDecoder().decode(h))},m.click()},j=typeof a.value=="string"&&/^0x[0-9A-F]+$/.test(a.value)?a.value.slice(2):null;return e.jsx(be,{wide:!0,title:i("Edit {name}",{name:a.title}),onClose:a.onClose,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:I,style:{marginRight:"auto"},children:i("Load from file…")}),j&&e.jsx("button",{className:"btn",onClick:()=>{const m=new Uint8Array(new ArrayBuffer(j.length/2));for(let y=0;y<m.length;y++)m[y]=parseInt(j.substr(y*2,2),16);const v=URL.createObjectURL(new Blob([m])),h=document.createElement("a");h.href=v,h.download=a.title+".bin",h.click()},children:i("Download current")}),e.jsx("button",{className:"btn",onClick:()=>a.onSave(null),children:i("Set NULL")}),e.jsx("button",{className:"btn",onClick:a.onClose,children:i("Cancel")}),e.jsx("button",{className:"btn primary",disabled:a.binary&&!d,onClick:()=>a.onSave(a.binary?{$hex:d.hex}:c),children:i("OK")})]}),children:a.binary?e.jsx("div",{className:"pad",children:d?e.jsxs("p",{children:[i("Selected")," ",e.jsx("b",{children:d.name})," ",i("({count} bytes). Click OK, then Save in the grid.",{count:d.size.toLocaleString()})]}):e.jsx("p",{className:"muted",children:j?i("Binary BLOB: load a file to replace the value (current: {count} bytes).",{count:j.length/2}):i("Binary BLOB: load a file to replace the value.")})}):e.jsx("textarea",{className:"text mono",style:{width:"100%",height:"50vh"},value:c,onChange:m=>E(m.target.value),autoFocus:!0})})}export{Ce as DataView};
1
+ import{r as u,j as e}from"./react-D1VdbdIl.js";import{u as ae,D as le,t as i,E as ie,j as oe,x as ce,F as re,o as de,p as ue,G as me,H as $,q as he,J as xe,b as H,f as G,M as be}from"./index-C1cNciQ3.js";import"./codemirror-CQtTaafu.js";import"./sql-formatter-BMeiBS2F.js";const fe=/INT|NUMERIC|DOUBLE|FLOAT|DECFLOAT/,R="FBADMIN$DB_KEY";function Ce(a){var z;const D=ae(),[c,E]=u.useState(null),[d,p]=u.useState([]),[I,j]=u.useState(null),[m,v]=u.useState(!1),[h,y]=u.useState(100),[x,O]=u.useState(0),[_,M]=u.useState(""),[U,Y]=u.useState(""),[K,J]=u.useState(!!a.showFilter),[b,Q]=u.useState(null),[T,g]=u.useState(null),[B,q]=u.useState(null),L=a.otype==="tables",[N,W]=u.useState(null),w=async(t=x)=>{v(!0),j(null);try{const s=await H.tableData(a.serverId,a.dbId,a.name,{limit:h,offset:t,..._?{where:_}:{},...b?{order_by:b.col,descending:b.desc}:{}});E(s),p(s.rows.map(r=>({values:[...r],orig:r,status:"clean"}))),O(t),q(null),g(null)}catch(s){j(G(s))}finally{v(!1)}};u.useEffect(()=>{w(0)},[h,_,b]);const C=(c==null?void 0:c.columns)??[],X=c?c.primary_key.length?c.primary_key:[R]:[],A=t=>c==null?void 0:c.column_meta.find(s=>s.name===t),k=C.map((t,s)=>({c:t,i:s})).filter(({c:t})=>t.name!==R),V=d.some(t=>t.status!=="clean"),F=(t,s,r)=>{p(n=>n.map((l,o)=>{if(o!==t)return l;const S=[...l.values];return S[s]=r,{...l,values:S,status:l.status==="new"?"new":"changed"}}))},Z=async()=>{if(!c)return;const t=n=>C.findIndex(l=>l.name===n),s=n=>Object.fromEntries(X.map(l=>[l,n.orig[t(l)]])),r={deletes:d.filter(n=>n.status==="deleted"&&n.orig).map(n=>({key:s(n)})),updates:d.filter(n=>n.status==="changed").map(n=>({key:s(n),values:Object.fromEntries(C.map((l,o)=>[l.name,n.values[o]]).filter(([l],o)=>l!==R&&n.values[o]!==n.orig[o]))})),inserts:d.filter(n=>n.status==="new").map(n=>({values:Object.fromEntries(C.map((l,o)=>[l.name,n.values[o]]).filter(([l,o])=>l!==R&&o!==void 0))}))};try{const n=await H.saveTableData(a.serverId,a.dbId,a.name,r);D.toast(i("Saved: {statements} statement(s), {affected} row(s)",{statements:n.statements,affected:n.affected})),w(x)}catch(n){D.toast(G(n),"error")}},ee=()=>{const t=C.map(()=>{});p(r=>[...r,{values:t,status:"new"}]);const s=k.find(({c:r})=>{var n,l;return!((n=A(r.name))!=null&&n.computed)&&!((l=A(r.name))!=null&&l.identity)});s&&g([d.length,s.i])};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{className:"toolbar",children:[e.jsx("button",{className:"btn icon",title:i("Refresh"),onClick:()=>w(x),children:e.jsx(le,{})}),e.jsx("button",{className:"btn icon"+(K?" on":""),title:i("Filter"),onClick:()=>J(!K),children:e.jsx(ie,{})}),L&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sep"}),e.jsxs("button",{className:"btn",onClick:ee,children:[e.jsx(oe,{})," ",i("Row")]}),e.jsxs("button",{className:"btn",disabled:B===null,onClick:()=>{B!==null&&p(t=>t.flatMap((s,r)=>r!==B?[s]:s.status==="new"?[]:[{...s,status:"deleted"}]))},children:[e.jsx(ce,{})," ",i("Delete")]}),e.jsxs("button",{className:"btn primary",disabled:!V,onClick:Z,children:[e.jsx(re,{})," ",i("Save")]}),e.jsx("button",{className:"btn",disabled:!V,onClick:()=>w(x),children:i("Discard")})]}),e.jsx("span",{className:"sep"}),e.jsxs("button",{className:"btn",disabled:x===0||m,onClick:()=>w(Math.max(0,x-h)),children:["‹ ",i("Prev")]}),e.jsx("span",{className:"muted",children:i("rows {from}–{to}",{from:d.length?x+1:0,to:x+((c==null?void 0:c.rows.length)??0)})}),e.jsxs("button",{className:"btn",disabled:!(c!=null&&c.has_more)||m,onClick:()=>w(x+h),children:[i("Next")," ›"]}),e.jsx("select",{className:"text",value:h,onChange:t=>y(Number(t.target.value)),children:[50,100,500,1e3,5e3].map(t=>e.jsx("option",{value:t,children:i("{count} / page",{count:t})},t))}),e.jsx("span",{className:"grow"}),c&&e.jsxs("button",{className:"btn small",onClick:()=>ue(`${a.name}.csv`,me(k.map(({c:t})=>t),d.map(t=>k.map(({i:s})=>t.values[s])))),children:[e.jsx(de,{size:13})," CSV"]})]}),K&&e.jsxs("div",{className:"toolbar",children:[e.jsx("span",{className:"muted",children:"WHERE"}),e.jsx("input",{className:"text mono",style:{flex:1},value:U,placeholder:i("e.g. NAME LIKE 'A%' AND ID > 10"),onChange:t=>Y(t.target.value),onKeyDown:t=>t.key==="Enter"&&M(U),autoFocus:!0}),e.jsx("button",{className:"btn",onClick:()=>M(U),children:i("Apply")}),e.jsx("button",{className:"btn",onClick:()=>{Y(""),M("")},children:i("Clear")})]}),I&&e.jsx("div",{className:"pad err",style:{whiteSpace:"pre-wrap"},children:I}),!L&&e.jsx("div",{className:"pad muted",style:{padding:"4px 10px"},children:a.otype==="views"?i("Read-only (view)."):i("Read-only (system table).")}),L&&c&&!c.primary_key.length&&e.jsx("div",{className:"pad warn",style:{padding:"4px 10px"},children:i("No primary key: rows are identified by RDB$DB_KEY (valid only within this session's view of the data).")}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[e.jsxs("table",{className:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"rn",children:"#"}),k.map(({c:t})=>{const s=A(t.name);return e.jsxs("th",{style:{cursor:"pointer"},onClick:()=>Q((b==null?void 0:b.col)===t.name?b.desc?null:{col:t.name,desc:!0}:{col:t.name,desc:!1}),children:[s!=null&&s.primary_key?"🔑 ":"",t.name," ",(b==null?void 0:b.col)===t.name?b.desc?"▼":"▲":"",e.jsxs("span",{className:"ty",children:[((s==null?void 0:s.data_type)??t.type).toLowerCase(),s!=null&&s.not_null?" not null":""]})]},t.name)})]})}),e.jsx("tbody",{children:d.map((t,s)=>e.jsxs("tr",{className:t.status==="clean"?"":t.status,onClick:()=>q(s),children:[e.jsx("td",{className:"rn",style:B===s?{color:"var(--accent)",fontWeight:700}:void 0,children:x+s+1}),k.map(({c:r,i:n})=>{const l=t.values[n],o=A(r.name),S=!L||t.status==="deleted"||!!(o!=null&&o.computed)||(o==null?void 0:o.identity)==="ALWAYS",te=T&&T[0]===s&&T[1]===n,se=t.orig&&t.values[n]!==t.orig[n],P=l===null,ne=[P?"null":"",fe.test(r.type)?"num":"",se?"dirty":""].join(" ");return te?e.jsx("td",{className:"sel",children:e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("input",{autoFocus:!0,defaultValue:l==null?"":$(l),onKeyDown:f=>{f.key==="Enter"&&(F(s,n,f.target.value),g(null)),f.key==="Escape"&&g(null)},onBlur:f=>{f.target.value!==(l==null?"":$(l))&&F(s,n,f.target.value),g(null)}}),e.jsx("button",{className:"btn small",title:i("Set NULL"),onMouseDown:f=>{f.preventDefault(),F(s,n,null),g(null)},children:"∅"}),e.jsx("button",{className:"btn small",title:i("Edit in a larger editor / upload a file"),onMouseDown:f=>{f.preventDefault(),g(null),W({ri:s,ci:n,name:r.name,blob:(o==null?void 0:o.field_type)===261,text:(o==null?void 0:o.field_sub_type)===1})},children:"…"})]})},r.name):e.jsx("td",{className:ne,onDoubleClick:()=>!S&&g([s,n]),title:S?void 0:i("Double-click to edit"),children:l===void 0?e.jsx("span",{className:"muted",children:o!=null&&o.identity||o!=null&&o.default?"default":""}):P?he().nullDisplay:ye(l)?e.jsx("span",{className:"muted",children:je(l)}):xe(l,r.type).slice(0,500)},r.name)})]},s))})]}),c&&d.length===0&&e.jsx("div",{className:"pad muted",children:i("No rows.")})]}),c&&e.jsx("div",{className:"status",children:e.jsx("span",{className:"mono",title:c.sql,children:c.sql.length>160?c.sql.slice(0,160)+"…":c.sql})}),N&&e.jsx(ve,{title:N.name,value:(z=d[N.ri])==null?void 0:z.values[N.ci],binary:N.blob&&!N.text,onClose:()=>W(null),onSave:t=>{F(N.ri,N.ci,t),W(null)}})]})}const ye=a=>typeof a=="string"&&(/^0x[0-9A-F]+$/.test(a)||a.startsWith("<BINARY")),je=a=>a.startsWith("<BINARY")?a.split(">")[0]+">":`<${(a.length-2)/2} bytes>`;function ve(a){const D=a.value===null||a.value===void 0||typeof a.value=="object"?"":$(a.value),[c,E]=u.useState(a.binary?"":D),[d,p]=u.useState(null),I=()=>{const m=document.createElement("input");m.type="file",m.onchange=async()=>{var x;const v=(x=m.files)==null?void 0:x[0];if(!v)return;const h=new Uint8Array(await v.arrayBuffer());let y="";for(const O of h)y+=O.toString(16).padStart(2,"0");a.binary?p({name:v.name,hex:y,size:h.length}):E(new TextDecoder().decode(h))},m.click()},j=typeof a.value=="string"&&/^0x[0-9A-F]+$/.test(a.value)?a.value.slice(2):null;return e.jsx(be,{wide:!0,title:i("Edit {name}",{name:a.title}),onClose:a.onClose,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:I,style:{marginRight:"auto"},children:i("Load from file…")}),j&&e.jsx("button",{className:"btn",onClick:()=>{const m=new Uint8Array(new ArrayBuffer(j.length/2));for(let y=0;y<m.length;y++)m[y]=parseInt(j.substr(y*2,2),16);const v=URL.createObjectURL(new Blob([m])),h=document.createElement("a");h.href=v,h.download=a.title+".bin",h.click()},children:i("Download current")}),e.jsx("button",{className:"btn",onClick:()=>a.onSave(null),children:i("Set NULL")}),e.jsx("button",{className:"btn",onClick:a.onClose,children:i("Cancel")}),e.jsx("button",{className:"btn primary",disabled:a.binary&&!d,onClick:()=>a.onSave(a.binary?{$hex:d.hex}:c),children:i("OK")})]}),children:a.binary?e.jsx("div",{className:"pad",children:d?e.jsxs("p",{children:[i("Selected")," ",e.jsx("b",{children:d.name})," ",i("({count} bytes). Click OK, then Save in the grid.",{count:d.size.toLocaleString()})]}):e.jsx("p",{className:"muted",children:j?i("Binary BLOB: load a file to replace the value (current: {count} bytes).",{count:j.length/2}):i("Binary BLOB: load a file to replace the value.")})}):e.jsx("textarea",{className:"text mono",style:{width:"100%",height:"50vh"},value:c,onChange:m=>E(m.target.value),autoFocus:!0})})}export{Ce as DataView};
@@ -1,2 +1,2 @@
1
- import{r as l,j as s}from"./react-D1VdbdIl.js";import{u as j,t as r,D as u,b as x,f as m,K as f}from"./index-BK8RZ2IB.js";import"./codemirror-CQtTaafu.js";import"./sql-formatter-BMeiBS2F.js";function w(o){const n=j(),[c,d]=l.useState([]),[e,i]=l.useState(null),a=async()=>{try{const t=await x.jobs();d(t),e&&i(await x.job(e.id))}catch{}};l.useEffect(()=>{if(!o.visible)return;a();const t=setInterval(a,1500);return()=>clearInterval(t)},[o.visible,e==null?void 0:e.id]);const v=t=>{var h;return((h=n.servers.find(p=>p.id===t))==null?void 0:h.name)??t};return s.jsxs("div",{style:{display:"flex",height:"100%"},children:[s.jsxs("div",{style:{width:460,borderRight:"1px solid var(--border)",overflow:"auto"},children:[s.jsxs("div",{className:"toolbar",children:[s.jsx("b",{children:r("Processes")}),s.jsx("span",{className:"grow"}),s.jsx("button",{className:"btn icon",onClick:a,children:s.jsx(u,{})})]}),c.length===0&&s.jsx("div",{className:"pad muted",children:r("No processes yet. Backups, restores, sweeps and statistics run here.")}),c.map(t=>s.jsxs("div",{className:"history-item",style:(e==null?void 0:e.id)===t.id?{background:"var(--select)"}:void 0,onClick:()=>x.job(t.id).then(i).catch(h=>n.toast(m(h),"error")),children:[s.jsx("span",{className:"pill "+t.status,children:r(t.status)})," ",s.jsx("b",{children:t.description}),s.jsxs("div",{className:"muted",children:[v(t.server_id)," · ",new Date(t.started_at*1e3).toLocaleString(),t.finished_at?` · ${(t.finished_at-t.started_at).toFixed(1)} s`:""]})]},t.id))]}),s.jsx("div",{style:{flex:1,padding:14,overflow:"auto"},children:e?s.jsxs(s.Fragment,{children:[s.jsxs("h2",{children:[e.description," ",s.jsx("span",{className:"pill "+e.status,children:r(e.status)})," ",s.jsx(f,{job:e,onCancel:i})]}),e.error&&s.jsx("p",{className:"err",children:e.error}),s.jsx("div",{className:"log",children:(e.log??[]).join(`
1
+ import{r as l,j as s}from"./react-D1VdbdIl.js";import{u as j,t as r,D as u,b as x,f as m,K as f}from"./index-C1cNciQ3.js";import"./codemirror-CQtTaafu.js";import"./sql-formatter-BMeiBS2F.js";function w(o){const n=j(),[c,d]=l.useState([]),[e,i]=l.useState(null),a=async()=>{try{const t=await x.jobs();d(t),e&&i(await x.job(e.id))}catch{}};l.useEffect(()=>{if(!o.visible)return;a();const t=setInterval(a,1500);return()=>clearInterval(t)},[o.visible,e==null?void 0:e.id]);const v=t=>{var h;return((h=n.servers.find(p=>p.id===t))==null?void 0:h.name)??t};return s.jsxs("div",{style:{display:"flex",height:"100%"},children:[s.jsxs("div",{style:{width:460,borderRight:"1px solid var(--border)",overflow:"auto"},children:[s.jsxs("div",{className:"toolbar",children:[s.jsx("b",{children:r("Processes")}),s.jsx("span",{className:"grow"}),s.jsx("button",{className:"btn icon",onClick:a,children:s.jsx(u,{})})]}),c.length===0&&s.jsx("div",{className:"pad muted",children:r("No processes yet. Backups, restores, sweeps and statistics run here.")}),c.map(t=>s.jsxs("div",{className:"history-item",style:(e==null?void 0:e.id)===t.id?{background:"var(--select)"}:void 0,onClick:()=>x.job(t.id).then(i).catch(h=>n.toast(m(h),"error")),children:[s.jsx("span",{className:"pill "+t.status,children:r(t.status)})," ",s.jsx("b",{children:t.description}),s.jsxs("div",{className:"muted",children:[v(t.server_id)," · ",new Date(t.started_at*1e3).toLocaleString(),t.finished_at?` · ${(t.finished_at-t.started_at).toFixed(1)} s`:""]})]},t.id))]}),s.jsx("div",{style:{flex:1,padding:14,overflow:"auto"},children:e?s.jsxs(s.Fragment,{children:[s.jsxs("h2",{children:[e.description," ",s.jsx("span",{className:"pill "+e.status,children:r(e.status)})," ",s.jsx(f,{job:e,onCancel:i})]}),e.error&&s.jsx("p",{className:"err",children:e.error}),s.jsx("div",{className:"log",children:(e.log??[]).join(`
2
2
  `)||r("(no output)")})]}):s.jsx("div",{className:"empty-state",children:r("Select a process to see its log.")})})]})}function S(o){const[n,c]=l.useState(null),[d,e]=l.useState(null),i=()=>x.serverLog(o.serverId).then(a=>c(a.log)).catch(a=>e(m(a)));return l.useEffect(()=>{i()},[]),s.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[s.jsx("div",{className:"toolbar",children:s.jsxs("button",{className:"btn",onClick:i,children:[s.jsx(u,{})," ",r("Refresh")]})}),s.jsx("div",{className:"pad",style:{flex:1,overflow:"auto"},children:d?s.jsx("div",{className:"err",children:d}):s.jsx("div",{className:"log",style:{maxHeight:"none"},children:n??r("Loading…")})})]})}export{w as JobsPanel,S as ServerLog};
@@ -1 +1 @@
1
- import{r,j as e}from"./react-D1VdbdIl.js";import{u as f,D as p,t,b as h,f as v,N as n}from"./index-BK8RZ2IB.js";import"./codemirror-CQtTaafu.js";import"./sql-formatter-BMeiBS2F.js";const N=[n("idle"),n("active"),n("stalled")],u=[n("consistency"),n("concurrency"),n("read committed (rec ver)"),n("read committed (no rec ver)"),n("read committed (read consistency)")];function I(i){const o=f(),[c,b]=r.useState(null),[j,x]=r.useState(null),[l,g]=r.useState(!0),a=()=>h.monitor(i.serverId,i.dbId).then(s=>{b(s),x(null)}).catch(s=>x(v(s)));r.useEffect(()=>{a()},[]),r.useEffect(()=>{if(!l||!i.visible)return;const s=setInterval(a,5e3);return()=>clearInterval(s)},[l,i.visible]);const m=async(s,d)=>{try{await s(),o.toast(d),a()}catch(_){o.toast(v(_),"error")}};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{className:"toolbar",children:[e.jsxs("button",{className:"btn",onClick:a,children:[e.jsx(p,{})," ",t("Refresh")]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:s=>g(s.target.checked)})," ",t("Auto-refresh (5 s)")]}),j&&e.jsx("span",{className:"err",children:j})]}),c&&e.jsxs("div",{className:"pad",style:{overflow:"auto"},children:[e.jsxs("div",{className:"cards",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Attachments")}),e.jsx("div",{className:"v",children:c.attachments.length})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Transactions")}),e.jsx("div",{className:"v",children:c.transactions.length})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Running statements")}),e.jsx("div",{className:"v",children:c.statements.length})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Next tx − OAT")}),e.jsx("div",{className:"v",children:(c.database.next_transaction-c.database.oat).toLocaleString()})]}),c.io&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Page reads / writes")}),e.jsxs("div",{className:"v",style:{fontSize:15},children:[Number(c.io.reads).toLocaleString()," / ",Number(c.io.writes).toLocaleString()]})]}),c.io&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Page fetches")}),e.jsx("div",{className:"v",style:{fontSize:15},children:Number(c.io.fetches).toLocaleString()})]})]}),e.jsx("h3",{children:t("Attachments")}),e.jsx("div",{className:"grid-wrap",children:e.jsxs("table",{className:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t("ID")}),e.jsx("th",{children:t("User")}),e.jsx("th",{children:t("Role")}),e.jsx("th",{children:t("Address")}),e.jsx("th",{children:t("Process")}),e.jsx("th",{children:t("State")}),e.jsx("th",{children:t("Connected")}),e.jsx("th",{children:t("Auth")}),e.jsx("th",{children:t("Charset")}),e.jsx("th",{children:t("Reads")}),e.jsx("th",{children:t("Writes")}),e.jsx("th",{})]})}),e.jsx("tbody",{children:c.attachments.map(s=>{var d;return e.jsxs("tr",{children:[e.jsxs("td",{children:[s.id,s.is_self?" (fbadmin)":""]}),e.jsx("td",{children:s.username}),e.jsx("td",{children:s.role_name}),e.jsx("td",{children:s.remote_address}),e.jsx("td",{title:s.remote_process,children:(s.remote_process??"").split(/[\\/]/).pop()}),e.jsx("td",{children:N[s.state]?t(N[s.state]):s.state}),e.jsx("td",{children:(d=s.connected_at)==null?void 0:d.replace("T"," ").slice(0,19)}),e.jsx("td",{children:s.auth_method}),e.jsx("td",{children:s.charset}),e.jsx("td",{className:"num",children:s.page_reads}),e.jsx("td",{className:"num",children:s.page_writes}),e.jsx("td",{children:!s.is_self&&e.jsx("button",{className:"btn small danger",onClick:()=>m(()=>h.killAttachment(i.serverId,i.dbId,s.id),t("Attachment {id} disconnected",{id:s.id})),children:t("Disconnect")})})]},s.id)})})]})}),e.jsx("h3",{children:t("Running statements")}),c.statements.length===0?e.jsx("div",{className:"muted",children:t("No running statements (other than fbadmin's own).")}):e.jsx("div",{className:"grid-wrap",children:e.jsxs("table",{className:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t("ID")}),e.jsx("th",{children:t("Attachment")}),e.jsx("th",{children:t("Transaction")}),e.jsx("th",{children:t("Started")}),e.jsx("th",{children:t("SQL")}),e.jsx("th",{})]})}),e.jsx("tbody",{children:c.statements.map(s=>{var d;return e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsx("td",{children:s.attachment_id}),e.jsx("td",{children:s.transaction_id}),e.jsx("td",{children:(d=s.started_at)==null?void 0:d.replace("T"," ").slice(0,19)}),e.jsx("td",{className:"mono",title:s.sql_text,style:{maxWidth:600},children:s.sql_text}),e.jsx("td",{children:e.jsx("button",{className:"btn small danger",onClick:()=>m(()=>h.cancelStatement(i.serverId,i.dbId,s.id),t("Statement {id} cancelled",{id:s.id})),children:t("Cancel")})})]},s.id)})})]})}),e.jsx("h3",{children:t("Transactions")}),e.jsx("div",{className:"grid-wrap",children:e.jsxs("table",{className:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t("ID")}),e.jsx("th",{children:t("Attachment")}),e.jsx("th",{children:t("State")}),e.jsx("th",{children:t("Started")}),e.jsx("th",{children:t("Isolation")}),e.jsx("th",{children:t("Read only")}),e.jsx("th",{children:t("Lock timeout")})]})}),e.jsx("tbody",{children:c.transactions.map(s=>{var d;return e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsx("td",{children:s.attachment_id}),e.jsx("td",{children:s.state===1?t("active"):t("idle")}),e.jsx("td",{children:(d=s.started_at)==null?void 0:d.replace("T"," ").slice(0,19)}),e.jsx("td",{children:u[s.isolation]?t(u[s.isolation]):s.isolation}),e.jsx("td",{children:s.read_only?t("yes"):""}),e.jsx("td",{children:s.lock_timeout===-1?t("wait"):s.lock_timeout===0?t("no wait"):`${s.lock_timeout}s`})]},s.id)})})]})})]})]})}export{I as Monitor};
1
+ import{r,j as e}from"./react-D1VdbdIl.js";import{u as f,D as p,t,b as h,f as v,N as n}from"./index-C1cNciQ3.js";import"./codemirror-CQtTaafu.js";import"./sql-formatter-BMeiBS2F.js";const N=[n("idle"),n("active"),n("stalled")],u=[n("consistency"),n("concurrency"),n("read committed (rec ver)"),n("read committed (no rec ver)"),n("read committed (read consistency)")];function I(i){const o=f(),[c,b]=r.useState(null),[j,x]=r.useState(null),[l,g]=r.useState(!0),a=()=>h.monitor(i.serverId,i.dbId).then(s=>{b(s),x(null)}).catch(s=>x(v(s)));r.useEffect(()=>{a()},[]),r.useEffect(()=>{if(!l||!i.visible)return;const s=setInterval(a,5e3);return()=>clearInterval(s)},[l,i.visible]);const m=async(s,d)=>{try{await s(),o.toast(d),a()}catch(_){o.toast(v(_),"error")}};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs("div",{className:"toolbar",children:[e.jsxs("button",{className:"btn",onClick:a,children:[e.jsx(p,{})," ",t("Refresh")]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:s=>g(s.target.checked)})," ",t("Auto-refresh (5 s)")]}),j&&e.jsx("span",{className:"err",children:j})]}),c&&e.jsxs("div",{className:"pad",style:{overflow:"auto"},children:[e.jsxs("div",{className:"cards",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Attachments")}),e.jsx("div",{className:"v",children:c.attachments.length})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Transactions")}),e.jsx("div",{className:"v",children:c.transactions.length})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Running statements")}),e.jsx("div",{className:"v",children:c.statements.length})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Next tx − OAT")}),e.jsx("div",{className:"v",children:(c.database.next_transaction-c.database.oat).toLocaleString()})]}),c.io&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Page reads / writes")}),e.jsxs("div",{className:"v",style:{fontSize:15},children:[Number(c.io.reads).toLocaleString()," / ",Number(c.io.writes).toLocaleString()]})]}),c.io&&e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"k",children:t("Page fetches")}),e.jsx("div",{className:"v",style:{fontSize:15},children:Number(c.io.fetches).toLocaleString()})]})]}),e.jsx("h3",{children:t("Attachments")}),e.jsx("div",{className:"grid-wrap",children:e.jsxs("table",{className:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t("ID")}),e.jsx("th",{children:t("User")}),e.jsx("th",{children:t("Role")}),e.jsx("th",{children:t("Address")}),e.jsx("th",{children:t("Process")}),e.jsx("th",{children:t("State")}),e.jsx("th",{children:t("Connected")}),e.jsx("th",{children:t("Auth")}),e.jsx("th",{children:t("Charset")}),e.jsx("th",{children:t("Reads")}),e.jsx("th",{children:t("Writes")}),e.jsx("th",{})]})}),e.jsx("tbody",{children:c.attachments.map(s=>{var d;return e.jsxs("tr",{children:[e.jsxs("td",{children:[s.id,s.is_self?" (fbadmin)":""]}),e.jsx("td",{children:s.username}),e.jsx("td",{children:s.role_name}),e.jsx("td",{children:s.remote_address}),e.jsx("td",{title:s.remote_process,children:(s.remote_process??"").split(/[\\/]/).pop()}),e.jsx("td",{children:N[s.state]?t(N[s.state]):s.state}),e.jsx("td",{children:(d=s.connected_at)==null?void 0:d.replace("T"," ").slice(0,19)}),e.jsx("td",{children:s.auth_method}),e.jsx("td",{children:s.charset}),e.jsx("td",{className:"num",children:s.page_reads}),e.jsx("td",{className:"num",children:s.page_writes}),e.jsx("td",{children:!s.is_self&&e.jsx("button",{className:"btn small danger",onClick:()=>m(()=>h.killAttachment(i.serverId,i.dbId,s.id),t("Attachment {id} disconnected",{id:s.id})),children:t("Disconnect")})})]},s.id)})})]})}),e.jsx("h3",{children:t("Running statements")}),c.statements.length===0?e.jsx("div",{className:"muted",children:t("No running statements (other than fbadmin's own).")}):e.jsx("div",{className:"grid-wrap",children:e.jsxs("table",{className:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t("ID")}),e.jsx("th",{children:t("Attachment")}),e.jsx("th",{children:t("Transaction")}),e.jsx("th",{children:t("Started")}),e.jsx("th",{children:t("SQL")}),e.jsx("th",{})]})}),e.jsx("tbody",{children:c.statements.map(s=>{var d;return e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsx("td",{children:s.attachment_id}),e.jsx("td",{children:s.transaction_id}),e.jsx("td",{children:(d=s.started_at)==null?void 0:d.replace("T"," ").slice(0,19)}),e.jsx("td",{className:"mono",title:s.sql_text,style:{maxWidth:600},children:s.sql_text}),e.jsx("td",{children:e.jsx("button",{className:"btn small danger",onClick:()=>m(()=>h.cancelStatement(i.serverId,i.dbId,s.id),t("Statement {id} cancelled",{id:s.id})),children:t("Cancel")})})]},s.id)})})]})}),e.jsx("h3",{children:t("Transactions")}),e.jsx("div",{className:"grid-wrap",children:e.jsxs("table",{className:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t("ID")}),e.jsx("th",{children:t("Attachment")}),e.jsx("th",{children:t("State")}),e.jsx("th",{children:t("Started")}),e.jsx("th",{children:t("Isolation")}),e.jsx("th",{children:t("Read only")}),e.jsx("th",{children:t("Lock timeout")})]})}),e.jsx("tbody",{children:c.transactions.map(s=>{var d;return e.jsxs("tr",{children:[e.jsx("td",{children:s.id}),e.jsx("td",{children:s.attachment_id}),e.jsx("td",{children:s.state===1?t("active"):t("idle")}),e.jsx("td",{children:(d=s.started_at)==null?void 0:d.replace("T"," ").slice(0,19)}),e.jsx("td",{children:u[s.isolation]?t(u[s.isolation]):s.isolation}),e.jsx("td",{children:s.read_only?t("yes"):""}),e.jsx("td",{children:s.lock_timeout===-1?t("wait"):s.lock_timeout===0?t("no wait"):`${s.lock_timeout}s`})]},s.id)})})]})})]})]})}export{I as Monitor};
@@ -0,0 +1,26 @@
1
+ import{r as c,j as e}from"./react-D1VdbdIl.js";import{r as Es,u as ws,s as Ke,a as Cs,b as y,c as B,d as _s,l as ks,e as Is,k as Xe,f as I,t,I as Rs,g as Ts,h as As,i as qs,A as Ms,j as Ls,m as Os,n as Ps,o as Ds,p as Ze,S as $s,q as Fs,R as Bs,P as Us,v as Ws,w as Hs,x as zs,y as Qs,N as j,z as Vs,B as Ys,C as Gs,M as Ks}from"./index-C1cNciQ3.js";import"./codemirror-CQtTaafu.js";import"./sql-formatter-BMeiBS2F.js";function Xs(a){const l=new Set;for(const d of a.matchAll(/"((?:[^"]|"")+)"|([A-Za-z_][A-Za-z0-9_$]*)/g))l.add(d[1]!==void 0?d[1].replace(/""/g,'"'):d[2].toUpperCase());return l}function Zs(a,l,d,p,u,h){const r=c.useRef(new Set),v=c.useRef(u);v.current=u,c.useEffect(()=>{if(!p)return;const o=setTimeout(()=>{const R=v.current,T=[...Xs(d)].filter(k=>k in R&&!r.current.has(k)).slice(0,200);T.length&&(T.forEach(k=>r.current.add(k)),Es("POST",`/api/servers/${a}/databases/${l}/completion/columns`,{relations:T}).then(k=>h(ae=>({...ae,...k.relations}))).catch(()=>T.forEach(k=>r.current.delete(k))))},400);return()=>clearTimeout(o)},[d,p])}const be=1e4,V="fbadmin.history",ge="fbadmin.snippets",ve="fbadmin.params";function U(a,l){try{const d=localStorage.getItem(a);return d?JSON.parse(d):l}catch{return l}}function Y(a,l){try{localStorage.setItem(a,JSON.stringify(l))}catch{}}function Js(a){Y(V,[a,...U(V,[]).filter(l=>l.sql!==a.sql)].slice(0,200))}const et=[{name:"Top statements by run time (MON$)",sql:`SELECT s.MON$ATTACHMENT_ID, s.MON$TIMESTAMP, s.MON$SQL_TEXT
2
+ FROM MON$STATEMENTS s
3
+ WHERE s.MON$STATE = 1
4
+ ORDER BY s.MON$TIMESTAMP;
5
+ `},{name:"Table sizes (record count estimate)",sql:`SELECT TRIM(r.RDB$RELATION_NAME) AS TABLE_NAME,
6
+ (SELECT COUNT(*) FROM RDB$RELATION_FIELDS f WHERE f.RDB$RELATION_NAME = r.RDB$RELATION_NAME) AS COLUMNS
7
+ FROM RDB$RELATIONS r
8
+ WHERE COALESCE(r.RDB$SYSTEM_FLAG, 0) = 0 AND r.RDB$VIEW_BLR IS NULL
9
+ ORDER BY 1;
10
+ `},{name:"Execute block",sql:`EXECUTE BLOCK RETURNS (N INTEGER)
11
+ AS
12
+ BEGIN
13
+ N = 1;
14
+ SUSPEND;
15
+ END;
16
+ `},{name:"Context variables",sql:`SELECT
17
+ RDB$GET_CONTEXT('SYSTEM', 'ENGINE_VERSION') AS ENGINE,
18
+ RDB$GET_CONTEXT('SYSTEM', 'CLIENT_ADDRESS') AS CLIENT,
19
+ CURRENT_USER, CURRENT_ROLE, CURRENT_CONNECTION, CURRENT_TRANSACTION
20
+ FROM RDB$DATABASE;
21
+ `}],st=/^\s*(create|alter|drop|recreate|declare|comment|grant|revoke)\b/im,Je=[["read_committed",j("Read committed"),3,j("Read committed")],["read_consistency",j("Read committed – read consistency"),4,j("Read committed")],["read_committed_no_rec_version",j("Read committed – no record version"),3,j("Read committed")],["snapshot",j("Snapshot (concurrency)"),3,j("Snapshot")],["snapshot_table_stability",j("Snapshot table stability (consistency)"),3,j("Snapshot table stability (consistency)")]],tt=[["fetches",j("Page fetches")],["reads",j("Page reads")],["writes",j("Page writes")],["marks",j("Page marks")],["seq_reads",j("Seq. reads")],["idx_reads",j("Index reads")],["inserts",j("Inserts")],["updates",j("Updates")],["deletes",j("Deletes")],["backouts",j("Backouts")],["purges",j("Purges")],["expunges",j("Expunges")]];function nt(a){const l=U(ve,{}),[d,p]=c.useState(Object.fromEntries(a.names.map(h=>[h,h in l?l[h]:""]))),u=()=>{Y(ve,{...U(ve,{}),...d}),a.onDone(d)};return e.jsx(Ks,{title:t("Query parameters"),onClose:()=>a.onDone(null),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>a.onDone(null),children:t("Cancel")}),e.jsx("button",{className:"btn primary",onClick:u,children:t("Execute")})]}),children:e.jsxs("div",{className:"form",onKeyDown:h=>h.key==="Enter"&&u(),children:[a.names.map((h,r)=>e.jsxs("div",{style:{display:"contents"},children:[e.jsx("label",{className:"l mono",children:h.startsWith("$")?`? #${h.slice(1)}`:`:${h}`}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("input",{className:"text mono",style:{flex:1},autoFocus:r===0,disabled:d[h]===null,value:d[h]??"",placeholder:d[h]===null?"NULL":"",onChange:v=>p({...d,[h]:v.target.value})}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:d[h]===null,onChange:v=>p({...d,[h]:v.target.checked?null:""})})," NULL"]})]})]},h)),e.jsx("span",{}),e.jsx("span",{className:"muted",children:t("Values are sent as text; Firebird converts them to the column type.")})]})})}function at(a){const[l,d]=c.useState(a.options),[p,u]=c.useState(null),h=l.engine_major>=4;return e.jsxs("div",{className:"popover",onMouseDown:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"form",children:[e.jsx("label",{className:"l",children:t("Isolation")}),e.jsx("select",{className:"text",value:l.isolation,onChange:r=>d({...l,isolation:r.target.value}),children:Je.map(([r,v,o])=>e.jsx("option",{value:r,disabled:l.engine_major<o,children:t(v)},r))}),e.jsx("span",{}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:l.read_only,onChange:r=>d({...l,read_only:r.target.checked})})," ",t("Read only")]}),e.jsx("label",{className:"l",children:t("Lock resolution")}),e.jsxs("select",{className:"text",value:l.wait?"wait":"nowait",onChange:r=>d({...l,wait:r.target.value==="wait"}),children:[e.jsx("option",{value:"wait",children:t("Wait")}),e.jsx("option",{value:"nowait",children:t("No wait")})]}),e.jsx("label",{className:"l",children:t("Lock timeout (s)")}),e.jsx("input",{className:"text",type:"number",min:0,disabled:!l.wait,value:l.lock_timeout??"",placeholder:t("infinite"),onChange:r=>d({...l,lock_timeout:r.target.value?Number(r.target.value):null})}),e.jsx("label",{className:"l",children:t("Statement timeout")}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"text",type:"number",min:0,disabled:!h,value:l.statement_timeout||"",placeholder:h?t("none"):"Firebird 4+",onChange:r=>d({...l,statement_timeout:Number(r.target.value||0)}),style:{flex:1}}),e.jsx("span",{className:"muted",children:"ms"})]})]}),p&&e.jsx("div",{className:"err",style:{marginTop:8,whiteSpace:"pre-wrap"},children:p}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:12},children:[e.jsx("button",{className:"btn",onClick:a.onClose,children:t("Close")}),e.jsx("button",{className:"btn primary",onClick:async()=>{try{await a.onApply({isolation:l.isolation,read_only:l.read_only,wait:l.wait,lock_timeout:l.wait?l.lock_timeout:null,statement_timeout:h?l.statement_timeout:void 0}),a.onClose()}catch(r){u(I(r))}},children:t("Apply")})]})]})}function lt(a){return e.jsx("pre",{className:"plan-tree",children:a.text.split(`
22
+ `).map((l,d)=>{const p=l.split(/(->\s*[A-Za-z][A-Za-z ]*?(?=\s"|$|\s\(|,)|Table (?:"[^"]+"\.)?"[^"]+"(?: as "[^"]+")?|Index (?:"[^"]+"\.)?"[^"]+")/g);return e.jsx("div",{children:p.map((u,h)=>u.startsWith("->")?e.jsx("span",{className:"op",children:u},h):u.startsWith("Table ")?e.jsx("span",{className:"tbl",children:u},h):u.startsWith("Index ")?e.jsx("span",{className:"idx",children:u},h):e.jsx("span",{children:u},h))},d)})})}function it(a){const l=tt.filter(([d])=>a.stats[d]);return l.length?e.jsx("table",{className:"stats-table",children:e.jsx("tbody",{children:e.jsx("tr",{children:l.map(([d,p])=>e.jsxs("td",{children:[e.jsx("span",{className:"muted",children:t(p)})," ",a.stats[d].toLocaleString()]},d))})})}):e.jsx("span",{className:"muted",children:t("no I/O")})}function rt(a){var h;const[l,d]=c.useState([]);c.useEffect(()=>{y.schemas(a.serverId,a.dbId).then(r=>d(r.schemas.map(v=>v.name))).catch(()=>d([]))},[a.serverId,a.dbId]);const p=/^\s*(?:"((?:[^"]|"")+)"|([^,\s]+))/.exec(a.searchPath??""),u=p?((h=p[1])==null?void 0:h.replace(/""/g,'"'))??p[2]:"";return e.jsxs("label",{title:t("Search path: {path}",{path:a.searchPath??""}),children:[t("Schema"),e.jsxs("select",{className:"text",value:u,onChange:r=>a.onChange(r.target.value),children:[!l.includes(u)&&e.jsx("option",{value:u,children:u}),l.map(r=>e.jsx("option",{value:r,children:r},r))]})]})}function ut(a){var ze,Qe,Ve;const l=ws(),[d,p]=c.useState(a.initialSql??""),[u,h]=c.useState(null),[r,v]=c.useState(null),[o,R]=c.useState(null),[T,k]=c.useState(!1),[ae,Se]=c.useState(null),[ye,le]=c.useState(!1),[W,es]=c.useState(!0),[P,ie]=c.useState(!1),Ee=c.useRef(`qt-${Math.random().toString(36).slice(2)}`).current;c.useEffect(()=>{Ke(Ee,P)},[P]),c.useEffect(()=>()=>Ke(Ee,!1),[]);const[G,ss]=c.useState(1e3),[re,oe]=c.useState(!1),[ts,we]=c.useState(!1),[ce,ns]=c.useState(!1),[Ce,as]=c.useState(!1),[C,E]=c.useState("data"),[K,_e]=c.useState(0),[S,X]=c.useState(null),[D,ke]=c.useState(null),[H,Z]=c.useState("graph"),[de,Ie]=c.useState(()=>U(V,[])),[J,Re]=c.useState(()=>U(ge,et)),[Te,Ae]=c.useState({}),[ls,is]=c.useState(!1);Zs(a.serverId,a.dbId,d,ls,Te,Ae);const[rs,os]=c.useState({}),[qe,cs]=c.useState(260),[me,Me]=c.useState(!1),[ue,he]=c.useState(null),[Le,Oe]=c.useState(!1),ee=Gs(),[$,Pe]=c.useState("grid"),[ds,ms]=c.useState([]),[us,hs]=c.useState(0),q=Cs(),[xs,xe]=c.useState(null),[fe,pe]=c.useState(!1),N=c.useRef(null),M=c.useRef(null),z=c.useRef(null),se=c.useCallback(async()=>M.current?M.current:(z.current??(z.current=y.openSession(a.serverId,a.dbId,a.schema).then(s=>(M.current=s.session_id,h(s.session_id),v(s.options),s.session_id)).finally(()=>{z.current=null})),z.current),[a.serverId,a.dbId]);c.useEffect(()=>(y.completion(a.serverId,a.dbId).then(s=>{Ae(s.relations),is(!!s.lazy_columns),os({procedures:s.procedures,functions:s.functions,packages:s.packages})}).catch(()=>{}),se().catch(()=>{}),a.autorun&&a.initialSql&&F(a.initialSql),()=>{M.current&&y.closeSession(M.current).catch(()=>{})}),[]),c.useEffect(()=>{if(!T)return;const s=performance.now(),n=setInterval(()=>hs(Math.round((performance.now()-s)/100)/10),100);return()=>clearInterval(n)},[T]);const fs=s=>new Promise(n=>he({names:s,resolve:n})),F=async(s,n={})=>{const m=G===0||!!n.fetchAll,i=N.current;let x=s??(i?B(i):d),w=0;if(i&&s===void 0){const f=i.state.selection.main;w=f.empty?0:f.from}else if(i&&s!==void 0){const f=i.state.selection.main;w=!f.empty&&i.state.sliceDoc(f.from,f.to)===s?f.from:0}if(!x.trim()||T)return;i&&_s(i);let ne;try{const f=(await y.queryParams(x)).params;if(f.length){const Q=await fs(f);if(he(null),!Q)return;ne=Q}}catch{}k(!0),X(null),Se(null);const A=performance.now();try{let f=await se();const Q={sql:x,autocommit:W,with_plan:ce,with_stats:Ce,max_rows:m?be:G,params:ne};let g;try{g=await y.runQuery(f,Q)}catch(b){if((b==null?void 0:b.status)===404)M.current=null,f=await se(),g=await y.runQuery(f,Q);else throw b}if(R(g),ie(g.transaction_open),m&&g.cursor_open&&!g.error){const b=g.results.filter(O=>O.kind==="select").slice(-1)[0];$e((b==null?void 0:b.rows)??[],f)}const Ye=g.results.filter(b=>b.kind==="select");if(_e(Math.max(0,Ye.length-1)),E(g.error?"messages":Ye.length?"data":"messages"),ce){const b=g.results.map(O=>O.plan).filter(Boolean).join(`
23
+
24
+ `);X({plan:b||null,detailed:null})}if(g.error&&i){const b=g.error,O=g.results[b.index],Ne=b.position??(O?{line:O.line,column:O.col??1}:null);if(Ne){const Ge=w+ks(x,Ne.line,Ne.column);Ge<=i.state.doc.length&&Is(i,Ge,b.message)}}Js({sql:x,at:Date.now(),ok:!g.error,ms:Math.round(performance.now()-A)}),Ie(U(V,[])),!g.error&&st.test(x)&&W&&l.invalidate(Xe.db(a.serverId,a.dbId))}catch(f){(f==null?void 0:f.status)===403&&f.code==="permission_denied"&&Se(x),R({results:[],error:{message:I(f),index:0,line:0,sql:x},elapsed_ms:0,transaction_open:P}),E("messages")}finally{k(!1),le(!1)}},ps=async()=>{if(M.current){le(!0);try{(await y.cancel(M.current)).cancelled||l.toast(t("Nothing to cancel (the statement may be finishing)"),"info")}catch(s){l.toast(I(s),"error"),le(!1)}}},De=async(s,n)=>{const m=performance.now(),i=await y.fetchMore(s,n),x=performance.now()-m;return R(w=>{if(!w)return w;const ne=w.results.map(A=>A.kind==="select"&&A===w.results.filter(f=>f.kind==="select").slice(-1)[0]?{...A,rows:[...A.rows??[],...i.rows],row_count:(A.row_count??0)+i.rows.length,truncated:i.has_more,fetch_ms:(A.fetch_ms??0)+x}:A);return{...w,results:ne,cursor_open:i.has_more,transaction_open:i.transaction_open}}),ie(i.transaction_open),i},je=c.useRef(!1),$e=async(s,n=u)=>{if(!n)return null;je.current=!1,we(!0);const m=[...s];try{for(;;){if(je.current)return null;const i=await De(n,be);if(m.push(...i.rows),!i.has_more)return m}}catch(i){return l.toast(I(i),"error"),R(x=>x&&{...x,cursor_open:!1}),null}finally{we(!1)}},Fe=async s=>{if(!u||!o)return{fetched:0,hasMore:!1};Oe(!0);try{const n=await De(u,s??(G||be));return{fetched:n.rows.length,hasMore:n.has_more}}catch(n){return l.toast(I(n),"error"),R(m=>m&&{...m,cursor_open:!1}),{fetched:0,hasMore:!1}}finally{Oe(!1)}},Be=async()=>{const s=N.current?B(N.current):d;try{const n=await se(),m=await y.explain(n,s);R(i=>i&&{...i,cursor_open:!1}),X(m.plan||m.detailed?{...m,sql:s}:{plan:t("(no plan — the statement does not read tables)"),detailed:null}),E("plan")}catch(n){X({plan:t("Error: {message}",{message:I(n)}),detailed:null}),E("plan")}},Ue=async s=>{if(u)try{await(s==="commit"?y.commit(u):y.rollback(u)),ie(!1),R(n=>n&&{...n,cursor_open:!1}),l.toast(s==="commit"?t("Transaction committed"):t("Transaction rolled back")),s==="commit"&&l.invalidate(Xe.db(a.serverId,a.dbId))}catch(n){l.toast(I(n),"error")}},js=async s=>{pe(!1);const n=N.current?B(N.current):d,m={task:s,sql:n,server_id:a.serverId,database_id:a.dbId};if(s==="convert_sql"){const i=window.prompt(t("Convert from which SQL dialect?"),"MySQL");if(!i)return;m.dialect=i}if(s==="ask"){const i=window.prompt(t("Your question about this SQL / database:"));if(!i)return;m.question=i}if(s==="explain_error"){if(!(o!=null&&o.error)){l.toast(t("No error to explain — run a query first"),"info");return}m.error=o.error.message,m.sql=o.error.sql}E("assistant"),xe({loading:!0,task:s});try{xe({loading:!1,task:s,answer:await Vs(m)})}catch(i){xe({loading:!1,task:s,error:I(i)})}},Ns=()=>{if(N.current)try{Ys(N.current)}catch(s){l.toast(t("Cannot format: {message}",{message:I(s)}),"error")}},We=s=>{const n=N.current;if(!n)return p(d+s);const m=n.state.selection.main,i=n.state.doc.lineAt(m.from),x=m.from>i.from&&i.text.trim()?`
25
+ `:"";n.dispatch({changes:{from:m.from,to:m.to,insert:x+s},selection:{anchor:m.from+x.length+s.length}}),n.focus()},bs=()=>{const s=N.current?B(N.current):d;if(!s.trim())return;const n=window.prompt(t("Snippet name"),s.trim().split(`
26
+ `)[0].slice(0,60));if(!n)return;const m=[{name:n,sql:s},...J.filter(i=>i.name!==n)];Re(m),Y(ge,m),E("snippets")},gs=()=>{const s=document.createElement("input");s.type="file",s.accept=".sql,.txt",s.onchange=async()=>{var m;const n=(m=s.files)==null?void 0:m[0];n&&p(await n.text())},s.click()},vs=s=>{const n=s.clientY,m=qe,i=w=>cs(Math.max(80,m+w.clientY-n)),x=()=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",x)};window.addEventListener("mousemove",i),window.addEventListener("mouseup",x)},L=(o==null?void 0:o.results.filter(s=>s.kind==="select"))??[],_=L[K],te=_&&_===L[L.length-1],He=r?(ze=Je.find(([s])=>s===r.isolation))==null?void 0:ze[3]:void 0,Ss=He?t(He):"",ys={serverId:a.serverId,dbId:a.dbId,setSql:p,selectionOrAll:()=>N.current?B(N.current):d,getSql:()=>{var s;return((s=N.current)==null?void 0:s.state.doc.toString())??d},refused:ae};return e.jsxs("div",{className:"qt",style:{display:a.visible?"flex":"none"},children:[e.jsxs("div",{className:"toolbar",children:[T?e.jsxs("button",{className:"btn stop",disabled:ye,onClick:ps,title:t("Cancel the running statement"),children:[e.jsx(Rs,{className:"spin"})," ",ye?t("Cancelling…"):t("Cancel ({seconds} s)",{seconds:us.toFixed(1)})]}):e.jsxs("div",{className:"split",style:{position:"relative"},children:[e.jsxs("button",{className:"btn primary",onClick:()=>F(),title:t("Execute (F5 / Ctrl+Enter). Runs the selection if any."),children:[e.jsx(Ts,{})," ",t("Execute")]}),e.jsx("button",{className:"btn primary","aria-label":t("More ways to execute"),"aria-haspopup":"menu","aria-expanded":re,onClick:()=>oe(!re),children:"▾"}),re&&e.jsx("div",{className:"ctx",role:"menu",style:{position:"absolute",left:0,top:"100%",minWidth:260,zIndex:20},onMouseLeave:()=>oe(!1),children:e.jsxs("button",{role:"menuitem",onClick:()=>{oe(!1),F(void 0,{fetchAll:!0})},title:t("Execute, then fetch every row of the result (whatever the Rows setting)"),children:[t("Execute + Fetch all")," ",e.jsx("span",{className:"muted",children:"Shift+F5 / Shift+Ctrl+Enter"})]})})]}),e.jsxs("button",{className:"btn",onClick:Be,title:t("Show the execution plan without running"),children:[e.jsx(As,{})," ",t("Explain")]}),r&&r.engine_major>=5&&e.jsx("button",{className:"btn",title:t("Run the statement under the Firebird 5 PSQL profiler (in a separate attachment) and show the report"),onClick:()=>{var m;const s=N.current?B(N.current):d;if(!s.trim())return;const n=(m=l.servers.find(i=>i.id===a.serverId))==null?void 0:m.databases.find(i=>i.id===a.dbId);l.openTab({kind:"profiler",title:`${(n==null?void 0:n.name)??"db"} · profile`,serverId:a.serverId,dbId:a.dbId,props:{sql:s,autorun:!0}})},children:t("Profile")}),e.jsx("span",{className:"sep"}),e.jsx("button",{className:"btn"+(W?" on":""),onClick:()=>es(!W),title:t("Commit after every statement"),children:W?t("Auto-commit on"):t("Auto-commit off")}),e.jsx("button",{className:"btn",disabled:!P,onClick:()=>Ue("commit"),children:t("Commit")}),e.jsx("button",{className:"btn",disabled:!P,onClick:()=>Ue("rollback"),children:t("Rollback")}),e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{className:"btn"+(me?" on":""),disabled:!r,onClick:()=>Me(!me),title:t("Transaction isolation, read-only, lock and statement timeouts"),children:[Ss,r!=null&&r.read_only?" · RO":"",r!=null&&r.statement_timeout?` · ${r.statement_timeout} ms`:""," ▾"]}),me&&r&&u&&e.jsx(at,{options:r,onClose:()=>Me(!1),onApply:async s=>v(await y.setOptions(u,s))})]}),r&&r.engine_major>=6&&u&&e.jsx(rt,{serverId:a.serverId,dbId:a.dbId,searchPath:r.search_path,onChange:async s=>{try{v(await y.setOptions(u,{search_schema:s})),qs(a.serverId,a.dbId,s)}catch(n){l.toast(I(n),"error")}}}),e.jsx("span",{className:"sep"}),e.jsxs("label",{children:[t("Rows"),e.jsxs("select",{className:"text",value:G,onChange:s=>ss(Number(s.target.value)),children:[[100,1e3,1e4,1e5].map(s=>e.jsx("option",{value:s,children:s.toLocaleString()},s)),e.jsx("option",{value:0,children:t("all")})]})]}),e.jsxs("label",{className:"check",title:t("Fetch the PLAN of every executed statement"),children:[e.jsx("input",{type:"checkbox",checked:ce,onChange:s=>ns(s.target.checked)})," ",t("Plans")]}),e.jsxs("label",{className:"check",title:t("Measure page and record I/O of every statement (from MON$ tables)"),children:[e.jsx("input",{type:"checkbox",checked:Ce,onChange:s=>as(s.target.checked)})," ",t("Stats")]}),e.jsx("span",{className:"grow"}),(q==null?void 0:q.enabled)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{className:"btn small"+(fe?" on":""),onClick:()=>pe(!fe),title:t("AI assistant ({provider})",{provider:q.provider??""}),children:["✦ ",t("Assistant")," ▾"]}),fe&&e.jsx("div",{className:"ctx",style:{position:"absolute",right:0,top:"100%"},onMouseLeave:()=>pe(!1),children:Ms.map(([s,n])=>e.jsx("button",{onClick:()=>js(s),children:t(n)},s))})]}),e.jsx("button",{className:"btn small",title:t("Format SQL (Shift+Alt+F)"),onClick:Ns,children:t("Format")}),e.jsx("button",{className:"btn icon",title:t("Save selection as snippet"),onClick:bs,children:e.jsx(Ls,{})}),Os().map(s=>e.jsx("span",{children:s.render(ys)},s.id)),e.jsx("button",{className:"btn icon",title:t("Open .sql file"),onClick:gs,children:e.jsx(Ps,{})}),e.jsx("button",{className:"btn icon",title:t("Save as .sql file"),onClick:()=>Ze("query.sql",d,"text/sql"),children:e.jsx(Ds,{})})]}),e.jsx("div",{className:"qt-editor",style:{height:qe},children:e.jsx($s,{value:d,onChange:p,onExecute:s=>F(s),onExecuteFetchAll:s=>F(s,{fetchAll:!0}),onExplain:()=>Be(),onMacro:s=>{const n=Fs().macros.find(w=>w.key===s),m=N.current;if(!n||!m)return;const i=m.state.selection.main,x=i.empty?"":m.state.sliceDoc(i.from,i.to);F(n.sql.split("$SELECTION$").join(x))},schema:Te,extra:rs,onFormatError:s=>l.toast(t("Cannot format: {message}",{message:s}),"error"),placeholder:t("-- Write SQL here. F5 / Ctrl+Enter runs the selection or the script. :name and ? prompt for values. Ctrl+/ comments, Shift+Alt+F formats."),editorRef:s=>N.current=s})}),e.jsx("div",{className:"splitter-h",onMouseDown:vs}),e.jsxs("div",{className:"qt-results",children:[e.jsxs("div",{className:"subtabs",children:[e.jsxs("button",{className:C==="data"?"active":"",onClick:()=>E("data"),children:[t("Data output"),L.length>1?` (${L.length})`:""]}),e.jsxs("button",{className:C==="messages"?"active":"",onClick:()=>E("messages"),children:[t("Messages")," ",(o==null?void 0:o.error)&&e.jsx("span",{className:"err",children:"●"})]}),e.jsx("button",{className:C==="plan"?"active":"",onClick:()=>E("plan"),children:t("Plan")}),e.jsx("button",{className:C==="history"?"active":"",onClick:()=>E("history"),children:t("History")}),e.jsx("button",{className:C==="snippets"?"active":"",onClick:()=>E("snippets"),children:t("Snippets")}),(q==null?void 0:q.enabled)&&e.jsx("button",{className:C==="assistant"?"active":"",onClick:()=>E("assistant"),children:t("Assistant")})]}),e.jsxs("div",{className:"qt-out",children:[C==="data"&&(_?e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(L.length>1||ee.length>0)&&e.jsxs("div",{className:"toolbar",children:[ee.length>0&&e.jsxs("div",{className:"seg",role:"group","aria-label":t("Result view"),children:[e.jsx("button",{className:$==="grid"?"on":"","aria-pressed":$==="grid",onClick:()=>Pe("grid"),children:t("Grid")}),ee.map(s=>e.jsxs("button",{className:$===s.id?"on":"","aria-pressed":$===s.id,onClick:()=>{Pe(s.id),ms(n=>n.includes(s.id)?n:[...n,s.id])},children:[s.icon," ",t(s.title)]},s.id))]}),L.length>1&&L.map((s,n)=>e.jsxs("button",{className:"btn small"+(n===K?" on":""),onClick:()=>_e(n),children:[t("Result {n}",{n:n+1})," ",e.jsx("span",{className:"muted",children:t("(line {line})",{line:s.line})})]},n))]}),e.jsx("div",{style:{flex:1,minHeight:0,display:$==="grid"?void 0:"none"},children:e.jsx(Bs,{columns:_.columns,rows:_.rows,hasMore:!!(te&&(o!=null&&o.cursor_open)),loadingMore:Le,onLoadMore:()=>Fe(),onFetchAll:te?()=>$e(_.rows??[]):void 0,fetchingAll:ts,onStopFetchAll:()=>{je.current=!0}},`${o==null?void 0:o.elapsed_ms}-${K}`)}),ee.filter(s=>ds.includes(s.id)).map(s=>e.jsx("div",{style:{flex:1,minHeight:0,display:$===s.id?void 0:"none"},children:s.render({columns:_.columns,rows:_.rows,hasMore:!!(te&&(o!=null&&o.cursor_open)),loadingMore:Le,loadMore:n=>te?Fe(n):Promise.resolve({fetched:0,hasMore:!1}),serverId:a.serverId,dbId:a.dbId,sql:_.sql})},`${s.id}-${o==null?void 0:o.elapsed_ms}-${K}`))]}):e.jsx("div",{className:"empty-state",children:o?t("The script returned no result set."):t("Run a query to see results.")})),C==="messages"&&e.jsxs("div",{className:"messages",children:[!o&&e.jsx("span",{className:"muted",children:t("No messages.")}),o==null?void 0:o.results.map(s=>{var n;return e.jsxs("div",{className:"stmt",children:[e.jsx("div",{className:"muted",children:t("-- line {line} · {ms} ms",{line:s.line,ms:s.elapsed_ms})}),e.jsx("div",{children:s.sql.length>300?s.sql.slice(0,300)+"…":s.sql}),e.jsxs("div",{className:s.kind==="error"?"err":"ok",children:[s.kind==="error"?t("ERROR:")+" ":"",s.kind==="select"?t("{count} row(s) fetched",{count:(s.row_count??((n=s.rows)==null?void 0:n.length)??0).toLocaleString()})+(s.truncated?" — "+t("more available"):""):s.message]}),!!s.fetch_ms&&e.jsx("div",{className:"muted",children:t("Fetched later: {ms} ms",{ms:s.fetch_ms.toFixed(2)})}),s.stats&&e.jsx(it,{stats:s.stats})]},s.index)}),(o==null?void 0:o.error)&&o.results.length===0&&e.jsx("div",{className:"err",children:o.error.message}),o&&e.jsx("div",{className:"muted",style:{paddingTop:8},children:t("Total: {ms} ms",{ms:(o.elapsed_ms+o.results.reduce((s,n)=>s+(n.fetch_ms??0),0)).toFixed(2)})})]}),C==="plan"&&(S?e.jsxs("div",{children:[e.jsxs("div",{className:"toolbar",children:[e.jsxs("div",{className:"seg",children:[e.jsx("button",{className:H==="graph"?"on":"",onClick:()=>Z("graph"),disabled:!S.detailed,children:t("Diagram")}),e.jsx("button",{className:H==="text"?"on":"",onClick:()=>Z("text"),children:t("Text")}),e.jsx("button",{className:H==="diff"?"on":"",onClick:()=>Z("diff"),disabled:!D,children:t("Compare with pinned")})]}),e.jsx("span",{className:"grow"}),e.jsx("button",{className:"btn small",onClick:()=>{ke(S),l.toast(t("Plan pinned — change the query, Explain again and compare"),"info")},children:t("Pin plan")}),D&&e.jsx("button",{className:"btn small",onClick:()=>{ke(null),Z("graph")},children:t("Unpin")})]}),H==="diff"&&D?e.jsx(Us,{left:D.detailed??D.plan??"",right:S.detailed??S.plan??"",leftTitle:t("Pinned: {sql}",{sql:(D.sql??"").slice(0,80)}),rightTitle:t("Current: {sql}",{sql:(S.sql??"").slice(0,80)})}):H==="graph"&&S.detailed?e.jsxs(e.Fragment,{children:[S.plan&&e.jsx("pre",{className:"plan mono",children:S.plan}),e.jsx(Ws,{text:S.detailed})]}):e.jsxs(e.Fragment,{children:[S.plan&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{margin:"12px 12px 0"},children:t("Plan")}),e.jsx("pre",{className:"plan mono",children:S.plan})]}),S.detailed&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{margin:"12px 12px 0"},children:t("Detailed plan")}),e.jsx(lt,{text:S.detailed})]})]})]}):e.jsx("div",{className:"empty-state",children:t("Click Explain, or enable Plans and execute.")})),C==="history"&&e.jsxs("div",{children:[de.length===0&&e.jsx("div",{className:"pad muted",children:t("No history yet.")}),de.length>0&&e.jsxs("div",{className:"toolbar",children:[e.jsx("span",{className:"grow"}),e.jsx("button",{className:"btn small",onClick:()=>{Y(V,[]),Ie([])},children:t("Clear history")})]}),de.map((s,n)=>e.jsxs("div",{className:"history-item",title:t("Click to load into the editor"),onClick:()=>p(s.sql),children:[e.jsx("span",{className:s.ok?"ok":"err",children:s.ok?"✓":"✗"})," ",e.jsxs("span",{className:"muted",children:[new Date(s.at).toLocaleString()," · ",s.ms," ms"]}),e.jsx("pre",{className:"mono",children:s.sql})]},n))]}),C==="assistant"&&e.jsx(Hs,{state:xs,status:q,onInsert:We}),C==="snippets"&&e.jsxs("div",{children:[e.jsxs("div",{className:"toolbar",children:[e.jsx("span",{className:"muted",children:t("Click to insert at the cursor. Use + in the toolbar to save the selection.")}),e.jsx("span",{className:"grow"}),e.jsx("button",{className:"btn small",onClick:()=>Ze("fbadmin-snippets.json",JSON.stringify(J,null,2),"application/json"),children:t("Export")})]}),J.map((s,n)=>e.jsxs("div",{className:"snippet",children:[e.jsxs("div",{style:{flex:1,cursor:"pointer",minWidth:0},onClick:()=>We(s.sql),children:[e.jsx("b",{children:s.name}),e.jsx("pre",{className:"mono",children:s.sql})]}),e.jsx("button",{className:"btn icon small",title:t("Delete snippet"),onClick:()=>{const m=J.filter((i,x)=>x!==n);Re(m),Y(ge,m)},children:e.jsx(zs,{size:13})})]},n))]})]})]}),e.jsxs("div",{className:"status",children:[e.jsx("span",{children:u?t("Connected · attachment {id}",{id:(r==null?void 0:r.attachment_id)??"?"}):t("Not connected")}),P&&e.jsx("span",{className:"tx",children:t("Transaction open — commit or rollback")}),(o==null?void 0:o.cursor_open)&&e.jsx("span",{children:t("Result set open")}),o&&e.jsx("span",{children:t("{count} statement(s) · {ms} ms",{count:o.results.length,ms:o.elapsed_ms})}),_&&e.jsx("span",{children:t("{count} rows",{count:`${((Qe=_.row_count)==null?void 0:Qe.toLocaleString())??""}${_.truncated?"+":""}`})}),(o==null?void 0:o.error)&&e.jsxs("span",{className:"err",style:{cursor:"pointer"},onClick:()=>E("messages"),children:[e.jsx(Qs,{size:11})," ",t("error at line {line}",{line:((Ve=o.error.position)==null?void 0:Ve.line)??o.error.line})]})]}),ue&&e.jsx(nt,{names:ue.names,onDone:s=>{he(null),ue.resolve(s)}})]})}export{ut as QueryTool};