spindb 0.37.2 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/bin.js +9 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/attach.js +102 -0
- package/dist/cli/commands/attach.js.map +1 -0
- package/dist/cli/commands/backup.js +197 -0
- package/dist/cli/commands/backup.js.map +1 -0
- package/dist/cli/commands/backups.js +190 -0
- package/dist/cli/commands/backups.js.map +1 -0
- package/dist/cli/commands/clone.js +119 -0
- package/dist/cli/commands/clone.js.map +1 -0
- package/dist/cli/commands/config.js +276 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/connect.js +559 -0
- package/dist/cli/commands/connect.js.map +1 -0
- package/dist/cli/commands/create.js +952 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/databases.js +485 -0
- package/dist/cli/commands/databases.js.map +1 -0
- package/dist/cli/commands/delete.js +106 -0
- package/dist/cli/commands/delete.js.map +1 -0
- package/dist/cli/commands/deps.js +238 -0
- package/dist/cli/commands/deps.js.map +1 -0
- package/dist/cli/commands/detach.js +81 -0
- package/dist/cli/commands/detach.js.map +1 -0
- package/dist/cli/commands/doctor.js +567 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/duckdb.js +207 -0
- package/dist/cli/commands/duckdb.js.map +1 -0
- package/dist/cli/commands/edit.js +524 -0
- package/dist/cli/commands/edit.js.map +1 -0
- package/dist/cli/commands/engines.js +1414 -0
- package/dist/cli/commands/engines.js.map +1 -0
- package/dist/cli/commands/export.js +383 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/info.js +270 -0
- package/dist/cli/commands/info.js.map +1 -0
- package/dist/cli/commands/list.js +215 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/logs.js +81 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/menu/backup-handlers.js +1202 -0
- package/dist/cli/commands/menu/backup-handlers.js.map +1 -0
- package/dist/cli/commands/menu/container-handlers.js +1788 -0
- package/dist/cli/commands/menu/container-handlers.js.map +1 -0
- package/dist/cli/commands/menu/engine-handlers.js +235 -0
- package/dist/cli/commands/menu/engine-handlers.js.map +1 -0
- package/dist/cli/commands/menu/index.js +266 -0
- package/dist/cli/commands/menu/index.js.map +1 -0
- package/dist/cli/commands/menu/settings-handlers.js +320 -0
- package/dist/cli/commands/menu/settings-handlers.js.map +1 -0
- package/dist/cli/commands/menu/shared.js +13 -0
- package/dist/cli/commands/menu/shared.js.map +1 -0
- package/dist/cli/commands/menu/shell-handlers.js +1573 -0
- package/dist/cli/commands/menu/shell-handlers.js.map +1 -0
- package/dist/cli/commands/menu/sql-handlers.js +185 -0
- package/dist/cli/commands/menu/sql-handlers.js.map +1 -0
- package/dist/cli/commands/menu/update-handlers.js +322 -0
- package/dist/cli/commands/menu/update-handlers.js.map +1 -0
- package/dist/cli/commands/menu/validators.js +9 -0
- package/dist/cli/commands/menu/validators.js.map +1 -0
- package/dist/cli/commands/ports.js +166 -0
- package/dist/cli/commands/ports.js.map +1 -0
- package/dist/cli/commands/pull.js +166 -0
- package/dist/cli/commands/pull.js.map +1 -0
- package/dist/cli/commands/query.js +180 -0
- package/dist/cli/commands/query.js.map +1 -0
- package/dist/cli/commands/restore.js +428 -0
- package/dist/cli/commands/restore.js.map +1 -0
- package/dist/cli/commands/run.js +115 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/self-update.js +99 -0
- package/dist/cli/commands/self-update.js.map +1 -0
- package/dist/cli/commands/sqlite.js +207 -0
- package/dist/cli/commands/sqlite.js.map +1 -0
- package/dist/cli/commands/start.js +196 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/stop.js +182 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/commands/url.js +88 -0
- package/dist/cli/commands/url.js.map +1 -0
- package/dist/cli/commands/users.js +189 -0
- package/dist/cli/commands/users.js.map +1 -0
- package/dist/cli/commands/version.js +52 -0
- package/dist/cli/commands/version.js.map +1 -0
- package/dist/cli/commands/which.js +258 -0
- package/dist/cli/commands/which.js.map +1 -0
- package/dist/cli/constants.js +212 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/helpers.js +1120 -0
- package/dist/cli/helpers.js.map +1 -0
- package/dist/cli/index.js +146 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/ui/prompts.js +1002 -0
- package/dist/cli/ui/prompts.js.map +1 -0
- package/dist/cli/ui/spinner.js +74 -0
- package/dist/cli/ui/spinner.js.map +1 -0
- package/dist/cli/ui/theme.js +99 -0
- package/dist/cli/ui/theme.js.map +1 -0
- package/dist/cli/utils/file-follower.js +79 -0
- package/dist/cli/utils/file-follower.js.map +1 -0
- package/dist/config/backup-formats.js +363 -0
- package/dist/config/backup-formats.js.map +1 -0
- package/dist/config/defaults.js +25 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/engine-defaults.js +303 -0
- package/dist/config/engine-defaults.js.map +1 -0
- package/dist/config/engines-registry.js +103 -0
- package/dist/config/engines-registry.js.map +1 -0
- package/dist/config/os-dependencies.js +767 -0
- package/dist/config/os-dependencies.js.map +1 -0
- package/dist/config/paths.js +156 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/version.js +3 -0
- package/dist/config/version.js.map +1 -0
- package/dist/core/backup-restore.js +219 -0
- package/dist/core/backup-restore.js.map +1 -0
- package/dist/core/base-binary-manager.js +403 -0
- package/dist/core/base-binary-manager.js.map +1 -0
- package/dist/core/base-document-binary-manager.js +364 -0
- package/dist/core/base-document-binary-manager.js.map +1 -0
- package/dist/core/base-embedded-binary-manager.js +364 -0
- package/dist/core/base-embedded-binary-manager.js.map +1 -0
- package/dist/core/base-server-binary-manager.js +368 -0
- package/dist/core/base-server-binary-manager.js.map +1 -0
- package/dist/core/config-manager.js +495 -0
- package/dist/core/config-manager.js.map +1 -0
- package/dist/core/container-manager.js +609 -0
- package/dist/core/container-manager.js.map +1 -0
- package/dist/core/credential-generator.js +67 -0
- package/dist/core/credential-generator.js.map +1 -0
- package/dist/core/credential-manager.js +211 -0
- package/dist/core/credential-manager.js.map +1 -0
- package/dist/core/dblab-utils.js +105 -0
- package/dist/core/dblab-utils.js.map +1 -0
- package/dist/core/dependency-manager.js +359 -0
- package/dist/core/dependency-manager.js.map +1 -0
- package/dist/core/docker-exporter.js +1077 -0
- package/dist/core/docker-exporter.js.map +1 -0
- package/dist/core/error-handler.js +295 -0
- package/dist/core/error-handler.js.map +1 -0
- package/dist/core/fs-error-utils.js +74 -0
- package/dist/core/fs-error-utils.js.map +1 -0
- package/dist/core/homebrew-version-manager.js +280 -0
- package/dist/core/homebrew-version-manager.js.map +1 -0
- package/dist/core/hostdb-client.js +252 -0
- package/dist/core/hostdb-client.js.map +1 -0
- package/dist/core/hostdb-metadata.js +243 -0
- package/dist/core/hostdb-metadata.js.map +1 -0
- package/dist/core/hostdb-releases-factory.js +161 -0
- package/dist/core/hostdb-releases-factory.js.map +1 -0
- package/dist/core/library-env.js +88 -0
- package/dist/core/library-env.js.map +1 -0
- package/dist/core/pgweb-utils.js +53 -0
- package/dist/core/pgweb-utils.js.map +1 -0
- package/dist/core/platform-service.js +632 -0
- package/dist/core/platform-service.js.map +1 -0
- package/dist/core/port-manager.js +136 -0
- package/dist/core/port-manager.js.map +1 -0
- package/dist/core/process-manager.js +445 -0
- package/dist/core/process-manager.js.map +1 -0
- package/dist/core/pull-manager.js +418 -0
- package/dist/core/pull-manager.js.map +1 -0
- package/dist/core/query-parser.js +449 -0
- package/dist/core/query-parser.js.map +1 -0
- package/dist/core/spawn-utils.js +90 -0
- package/dist/core/spawn-utils.js.map +1 -0
- package/dist/core/start-with-retry.js +90 -0
- package/dist/core/start-with-retry.js.map +1 -0
- package/dist/core/test-cleanup.js +85 -0
- package/dist/core/test-cleanup.js.map +1 -0
- package/dist/core/tls-generator.js +84 -0
- package/dist/core/tls-generator.js.map +1 -0
- package/dist/core/transaction-manager.js +139 -0
- package/dist/core/transaction-manager.js.map +1 -0
- package/dist/core/update-manager.js +241 -0
- package/dist/core/update-manager.js.map +1 -0
- package/dist/core/version-migration.js +260 -0
- package/dist/core/version-migration.js.map +1 -0
- package/dist/core/version-utils.js +91 -0
- package/dist/core/version-utils.js.map +1 -0
- package/dist/engines/base-engine.js +179 -0
- package/dist/engines/base-engine.js.map +1 -0
- package/dist/engines/clickhouse/backup.js +289 -0
- package/dist/engines/clickhouse/backup.js.map +1 -0
- package/dist/engines/clickhouse/binary-manager.js +145 -0
- package/dist/engines/clickhouse/binary-manager.js.map +1 -0
- package/dist/engines/clickhouse/binary-urls.js +100 -0
- package/dist/engines/clickhouse/binary-urls.js.map +1 -0
- package/dist/engines/clickhouse/cli-utils.js +143 -0
- package/dist/engines/clickhouse/cli-utils.js.map +1 -0
- package/dist/engines/clickhouse/hostdb-releases.js +24 -0
- package/dist/engines/clickhouse/hostdb-releases.js.map +1 -0
- package/dist/engines/clickhouse/index.js +1077 -0
- package/dist/engines/clickhouse/index.js.map +1 -0
- package/dist/engines/clickhouse/restore.js +335 -0
- package/dist/engines/clickhouse/restore.js.map +1 -0
- package/dist/engines/clickhouse/version-maps.js +83 -0
- package/dist/engines/clickhouse/version-maps.js.map +1 -0
- package/dist/engines/clickhouse/version-validator.js +133 -0
- package/dist/engines/clickhouse/version-validator.js.map +1 -0
- package/dist/engines/cockroachdb/backup.js +261 -0
- package/dist/engines/cockroachdb/backup.js.map +1 -0
- package/dist/engines/cockroachdb/binary-manager.js +33 -0
- package/dist/engines/cockroachdb/binary-manager.js.map +1 -0
- package/dist/engines/cockroachdb/binary-urls.js +33 -0
- package/dist/engines/cockroachdb/binary-urls.js.map +1 -0
- package/dist/engines/cockroachdb/cli-utils.js +338 -0
- package/dist/engines/cockroachdb/cli-utils.js.map +1 -0
- package/dist/engines/cockroachdb/hostdb-releases.js +21 -0
- package/dist/engines/cockroachdb/hostdb-releases.js.map +1 -0
- package/dist/engines/cockroachdb/index.js +1016 -0
- package/dist/engines/cockroachdb/index.js.map +1 -0
- package/dist/engines/cockroachdb/restore.js +323 -0
- package/dist/engines/cockroachdb/restore.js.map +1 -0
- package/dist/engines/cockroachdb/version-maps.js +37 -0
- package/dist/engines/cockroachdb/version-maps.js.map +1 -0
- package/dist/engines/couchdb/api-client.js +64 -0
- package/dist/engines/couchdb/api-client.js.map +1 -0
- package/dist/engines/couchdb/backup.js +90 -0
- package/dist/engines/couchdb/backup.js.map +1 -0
- package/dist/engines/couchdb/binary-manager.js +62 -0
- package/dist/engines/couchdb/binary-manager.js.map +1 -0
- package/dist/engines/couchdb/binary-urls.js +92 -0
- package/dist/engines/couchdb/binary-urls.js.map +1 -0
- package/dist/engines/couchdb/hostdb-releases.js +21 -0
- package/dist/engines/couchdb/hostdb-releases.js.map +1 -0
- package/dist/engines/couchdb/index.js +1043 -0
- package/dist/engines/couchdb/index.js.map +1 -0
- package/dist/engines/couchdb/restore.js +198 -0
- package/dist/engines/couchdb/restore.js.map +1 -0
- package/dist/engines/couchdb/version-maps.js +67 -0
- package/dist/engines/couchdb/version-maps.js.map +1 -0
- package/dist/engines/couchdb/version-validator.js +88 -0
- package/dist/engines/couchdb/version-validator.js.map +1 -0
- package/dist/engines/duckdb/binary-manager.js +33 -0
- package/dist/engines/duckdb/binary-manager.js.map +1 -0
- package/{engines/duckdb/binary-urls.ts → dist/engines/duckdb/binary-urls.js} +11 -16
- package/dist/engines/duckdb/binary-urls.js.map +1 -0
- package/dist/engines/duckdb/hostdb-releases.js +21 -0
- package/dist/engines/duckdb/hostdb-releases.js.map +1 -0
- package/dist/engines/duckdb/index.js +594 -0
- package/dist/engines/duckdb/index.js.map +1 -0
- package/dist/engines/duckdb/registry.js +265 -0
- package/dist/engines/duckdb/registry.js.map +1 -0
- package/dist/engines/duckdb/scanner.js +12 -0
- package/dist/engines/duckdb/scanner.js.map +1 -0
- package/dist/engines/duckdb/version-maps.js +67 -0
- package/dist/engines/duckdb/version-maps.js.map +1 -0
- package/dist/engines/duckdb/version-validator.js +62 -0
- package/dist/engines/duckdb/version-validator.js.map +1 -0
- package/dist/engines/ferretdb/backup.js +170 -0
- package/dist/engines/ferretdb/backup.js.map +1 -0
- package/dist/engines/ferretdb/binary-manager.js +765 -0
- package/dist/engines/ferretdb/binary-manager.js.map +1 -0
- package/dist/engines/ferretdb/binary-urls.js +135 -0
- package/dist/engines/ferretdb/binary-urls.js.map +1 -0
- package/dist/engines/ferretdb/index.js +1517 -0
- package/dist/engines/ferretdb/index.js.map +1 -0
- package/dist/engines/ferretdb/restore.js +310 -0
- package/dist/engines/ferretdb/restore.js.map +1 -0
- package/{engines/ferretdb/version-maps.ts → dist/engines/ferretdb/version-maps.js} +62 -79
- package/dist/engines/ferretdb/version-maps.js.map +1 -0
- package/dist/engines/file-based-utils.js +184 -0
- package/dist/engines/file-based-utils.js.map +1 -0
- package/dist/engines/index.js +124 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/engines/influxdb/api-client.js +54 -0
- package/dist/engines/influxdb/api-client.js.map +1 -0
- package/dist/engines/influxdb/backup.js +119 -0
- package/dist/engines/influxdb/backup.js.map +1 -0
- package/dist/engines/influxdb/binary-manager.js +87 -0
- package/dist/engines/influxdb/binary-manager.js.map +1 -0
- package/dist/engines/influxdb/binary-urls.js +56 -0
- package/dist/engines/influxdb/binary-urls.js.map +1 -0
- package/dist/engines/influxdb/hostdb-releases.js +21 -0
- package/dist/engines/influxdb/hostdb-releases.js.map +1 -0
- package/dist/engines/influxdb/index.js +962 -0
- package/dist/engines/influxdb/index.js.map +1 -0
- package/dist/engines/influxdb/restore.js +329 -0
- package/dist/engines/influxdb/restore.js.map +1 -0
- package/dist/engines/influxdb/version-maps.js +64 -0
- package/dist/engines/influxdb/version-maps.js.map +1 -0
- package/dist/engines/influxdb/version-validator.js +109 -0
- package/dist/engines/influxdb/version-validator.js.map +1 -0
- package/dist/engines/mariadb/backup.js +178 -0
- package/dist/engines/mariadb/backup.js.map +1 -0
- package/dist/engines/mariadb/binary-manager.js +33 -0
- package/dist/engines/mariadb/binary-manager.js.map +1 -0
- package/{engines/mariadb/binary-urls.ts → dist/engines/mariadb/binary-urls.js} +38 -55
- package/dist/engines/mariadb/binary-urls.js.map +1 -0
- package/dist/engines/mariadb/hostdb-releases.js +21 -0
- package/dist/engines/mariadb/hostdb-releases.js.map +1 -0
- package/dist/engines/mariadb/index.js +1011 -0
- package/dist/engines/mariadb/index.js.map +1 -0
- package/dist/engines/mariadb/restore.js +322 -0
- package/dist/engines/mariadb/restore.js.map +1 -0
- package/dist/engines/mariadb/version-maps.js +63 -0
- package/dist/engines/mariadb/version-maps.js.map +1 -0
- package/dist/engines/mariadb/version-validator.js +143 -0
- package/dist/engines/mariadb/version-validator.js.map +1 -0
- package/dist/engines/meilisearch/api-client.js +50 -0
- package/dist/engines/meilisearch/api-client.js.map +1 -0
- package/dist/engines/meilisearch/backup.js +167 -0
- package/dist/engines/meilisearch/backup.js.map +1 -0
- package/dist/engines/meilisearch/binary-manager.js +31 -0
- package/dist/engines/meilisearch/binary-manager.js.map +1 -0
- package/dist/engines/meilisearch/binary-urls.js +56 -0
- package/dist/engines/meilisearch/binary-urls.js.map +1 -0
- package/dist/engines/meilisearch/hostdb-releases.js +21 -0
- package/dist/engines/meilisearch/hostdb-releases.js.map +1 -0
- package/dist/engines/meilisearch/index.js +992 -0
- package/dist/engines/meilisearch/index.js.map +1 -0
- package/dist/engines/meilisearch/restore.js +167 -0
- package/dist/engines/meilisearch/restore.js.map +1 -0
- package/dist/engines/meilisearch/version-maps.js +67 -0
- package/dist/engines/meilisearch/version-maps.js.map +1 -0
- package/dist/engines/meilisearch/version-validator.js +109 -0
- package/dist/engines/meilisearch/version-validator.js.map +1 -0
- package/dist/engines/mongodb/backup.js +109 -0
- package/dist/engines/mongodb/backup.js.map +1 -0
- package/dist/engines/mongodb/binary-manager.js +36 -0
- package/dist/engines/mongodb/binary-manager.js.map +1 -0
- package/dist/engines/mongodb/binary-urls.js +46 -0
- package/dist/engines/mongodb/binary-urls.js.map +1 -0
- package/dist/engines/mongodb/cli-utils.js +131 -0
- package/dist/engines/mongodb/cli-utils.js.map +1 -0
- package/dist/engines/mongodb/hostdb-releases.js +77 -0
- package/dist/engines/mongodb/hostdb-releases.js.map +1 -0
- package/dist/engines/mongodb/index.js +873 -0
- package/dist/engines/mongodb/index.js.map +1 -0
- package/dist/engines/mongodb/restore.js +276 -0
- package/dist/engines/mongodb/restore.js.map +1 -0
- package/dist/engines/mongodb/version-maps.js +79 -0
- package/dist/engines/mongodb/version-maps.js.map +1 -0
- package/dist/engines/mongodb/version-validator.js +133 -0
- package/dist/engines/mongodb/version-validator.js.map +1 -0
- package/dist/engines/mysql/backup.js +210 -0
- package/dist/engines/mysql/backup.js.map +1 -0
- package/dist/engines/mysql/binary-detection.js +325 -0
- package/dist/engines/mysql/binary-detection.js.map +1 -0
- package/dist/engines/mysql/binary-manager.js +30 -0
- package/dist/engines/mysql/binary-manager.js.map +1 -0
- package/dist/engines/mysql/binary-urls.js +87 -0
- package/dist/engines/mysql/binary-urls.js.map +1 -0
- package/{engines/mysql/hostdb-releases.ts → dist/engines/mysql/hostdb-releases.js} +20 -23
- package/dist/engines/mysql/hostdb-releases.js.map +1 -0
- package/dist/engines/mysql/index.js +1066 -0
- package/dist/engines/mysql/index.js.map +1 -0
- package/dist/engines/mysql/restore.js +361 -0
- package/dist/engines/mysql/restore.js.map +1 -0
- package/dist/engines/mysql/version-maps.js +79 -0
- package/dist/engines/mysql/version-maps.js.map +1 -0
- package/dist/engines/mysql/version-validator.js +266 -0
- package/dist/engines/mysql/version-validator.js.map +1 -0
- package/dist/engines/postgresql/backup.js +118 -0
- package/dist/engines/postgresql/backup.js.map +1 -0
- package/dist/engines/postgresql/binary-manager.js +85 -0
- package/dist/engines/postgresql/binary-manager.js.map +1 -0
- package/dist/engines/postgresql/binary-urls.js +80 -0
- package/dist/engines/postgresql/binary-urls.js.map +1 -0
- package/dist/engines/postgresql/hostdb-releases.js +21 -0
- package/dist/engines/postgresql/hostdb-releases.js.map +1 -0
- package/dist/engines/postgresql/index.js +852 -0
- package/dist/engines/postgresql/index.js.map +1 -0
- package/dist/engines/postgresql/remote-version.js +109 -0
- package/dist/engines/postgresql/remote-version.js.map +1 -0
- package/dist/engines/postgresql/restore.js +254 -0
- package/dist/engines/postgresql/restore.js.map +1 -0
- package/dist/engines/postgresql/version-maps.js +73 -0
- package/dist/engines/postgresql/version-maps.js.map +1 -0
- package/dist/engines/postgresql/version-validator.js +286 -0
- package/dist/engines/postgresql/version-validator.js.map +1 -0
- package/dist/engines/qdrant/api-client.js +50 -0
- package/dist/engines/qdrant/api-client.js.map +1 -0
- package/dist/engines/qdrant/backup.js +115 -0
- package/dist/engines/qdrant/backup.js.map +1 -0
- package/dist/engines/qdrant/binary-manager.js +31 -0
- package/dist/engines/qdrant/binary-manager.js.map +1 -0
- package/dist/engines/qdrant/binary-urls.js +92 -0
- package/dist/engines/qdrant/binary-urls.js.map +1 -0
- package/dist/engines/qdrant/cli-utils.js +39 -0
- package/dist/engines/qdrant/cli-utils.js.map +1 -0
- package/dist/engines/qdrant/hostdb-releases.js +21 -0
- package/dist/engines/qdrant/hostdb-releases.js.map +1 -0
- package/dist/engines/qdrant/index.js +1002 -0
- package/dist/engines/qdrant/index.js.map +1 -0
- package/dist/engines/qdrant/restore.js +154 -0
- package/dist/engines/qdrant/restore.js.map +1 -0
- package/dist/engines/qdrant/version-maps.js +67 -0
- package/dist/engines/qdrant/version-maps.js.map +1 -0
- package/dist/engines/qdrant/version-validator.js +109 -0
- package/dist/engines/qdrant/version-validator.js.map +1 -0
- package/dist/engines/questdb/backup.js +191 -0
- package/dist/engines/questdb/backup.js.map +1 -0
- package/dist/engines/questdb/binary-manager.js +247 -0
- package/dist/engines/questdb/binary-manager.js.map +1 -0
- package/dist/engines/questdb/binary-urls.js +27 -0
- package/dist/engines/questdb/binary-urls.js.map +1 -0
- package/dist/engines/questdb/hostdb-releases.js +21 -0
- package/dist/engines/questdb/hostdb-releases.js.map +1 -0
- package/dist/engines/questdb/index.js +814 -0
- package/dist/engines/questdb/index.js.map +1 -0
- package/dist/engines/questdb/restore.js +202 -0
- package/dist/engines/questdb/restore.js.map +1 -0
- package/dist/engines/questdb/version-maps.js +33 -0
- package/dist/engines/questdb/version-maps.js.map +1 -0
- package/dist/engines/questdb/version-validator.js +99 -0
- package/dist/engines/questdb/version-validator.js.map +1 -0
- package/dist/engines/redis/backup.js +292 -0
- package/dist/engines/redis/backup.js.map +1 -0
- package/dist/engines/redis/binary-manager.js +32 -0
- package/dist/engines/redis/binary-manager.js.map +1 -0
- package/dist/engines/redis/binary-urls.js +96 -0
- package/dist/engines/redis/binary-urls.js.map +1 -0
- package/dist/engines/redis/cli-utils.js +38 -0
- package/dist/engines/redis/cli-utils.js.map +1 -0
- package/dist/engines/redis/hostdb-releases.js +21 -0
- package/dist/engines/redis/hostdb-releases.js.map +1 -0
- package/dist/engines/redis/index.js +1263 -0
- package/dist/engines/redis/index.js.map +1 -0
- package/dist/engines/redis/restore.js +338 -0
- package/dist/engines/redis/restore.js.map +1 -0
- package/dist/engines/redis/version-maps.js +70 -0
- package/dist/engines/redis/version-maps.js.map +1 -0
- package/dist/engines/redis/version-validator.js +109 -0
- package/dist/engines/redis/version-validator.js.map +1 -0
- package/dist/engines/sqlite/binary-manager.js +39 -0
- package/dist/engines/sqlite/binary-manager.js.map +1 -0
- package/{engines/sqlite/binary-urls.ts → dist/engines/sqlite/binary-urls.js} +11 -16
- package/dist/engines/sqlite/binary-urls.js.map +1 -0
- package/dist/engines/sqlite/hostdb-releases.js +21 -0
- package/dist/engines/sqlite/hostdb-releases.js.map +1 -0
- package/dist/engines/sqlite/index.js +493 -0
- package/dist/engines/sqlite/index.js.map +1 -0
- package/dist/engines/sqlite/registry.js +163 -0
- package/dist/engines/sqlite/registry.js.map +1 -0
- package/dist/engines/sqlite/scanner.js +12 -0
- package/dist/engines/sqlite/scanner.js.map +1 -0
- package/dist/engines/sqlite/version-maps.js +57 -0
- package/dist/engines/sqlite/version-maps.js.map +1 -0
- package/dist/engines/surrealdb/backup.js +97 -0
- package/dist/engines/surrealdb/backup.js.map +1 -0
- package/dist/engines/surrealdb/binary-manager.js +33 -0
- package/dist/engines/surrealdb/binary-manager.js.map +1 -0
- package/dist/engines/surrealdb/binary-urls.js +33 -0
- package/dist/engines/surrealdb/binary-urls.js.map +1 -0
- package/dist/engines/surrealdb/cli-utils.js +147 -0
- package/dist/engines/surrealdb/cli-utils.js.map +1 -0
- package/dist/engines/surrealdb/hostdb-releases.js +21 -0
- package/dist/engines/surrealdb/hostdb-releases.js.map +1 -0
- package/dist/engines/surrealdb/index.js +1022 -0
- package/dist/engines/surrealdb/index.js.map +1 -0
- package/dist/engines/surrealdb/restore.js +224 -0
- package/dist/engines/surrealdb/restore.js.map +1 -0
- package/dist/engines/surrealdb/version-maps.js +36 -0
- package/dist/engines/surrealdb/version-maps.js.map +1 -0
- package/dist/engines/tigerbeetle/backup.js +36 -0
- package/dist/engines/tigerbeetle/backup.js.map +1 -0
- package/dist/engines/tigerbeetle/binary-manager.js +72 -0
- package/dist/engines/tigerbeetle/binary-manager.js.map +1 -0
- package/dist/engines/tigerbeetle/binary-urls.js +49 -0
- package/dist/engines/tigerbeetle/binary-urls.js.map +1 -0
- package/dist/engines/tigerbeetle/hostdb-releases.js +21 -0
- package/dist/engines/tigerbeetle/hostdb-releases.js.map +1 -0
- package/dist/engines/tigerbeetle/index.js +559 -0
- package/dist/engines/tigerbeetle/index.js.map +1 -0
- package/dist/engines/tigerbeetle/restore.js +91 -0
- package/dist/engines/tigerbeetle/restore.js.map +1 -0
- package/{engines/tigerbeetle/version-maps.ts → dist/engines/tigerbeetle/version-maps.js} +22 -31
- package/dist/engines/tigerbeetle/version-maps.js.map +1 -0
- package/dist/engines/tigerbeetle/version-validator.js +108 -0
- package/dist/engines/tigerbeetle/version-validator.js.map +1 -0
- package/dist/engines/typedb/backup.js +129 -0
- package/dist/engines/typedb/backup.js.map +1 -0
- package/dist/engines/typedb/binary-manager.js +151 -0
- package/dist/engines/typedb/binary-manager.js.map +1 -0
- package/dist/engines/typedb/binary-urls.js +33 -0
- package/dist/engines/typedb/binary-urls.js.map +1 -0
- package/dist/engines/typedb/cli-utils.js +163 -0
- package/dist/engines/typedb/cli-utils.js.map +1 -0
- package/dist/engines/typedb/hostdb-releases.js +21 -0
- package/dist/engines/typedb/hostdb-releases.js.map +1 -0
- package/dist/engines/typedb/index.js +1003 -0
- package/dist/engines/typedb/index.js.map +1 -0
- package/dist/engines/typedb/restore.js +279 -0
- package/dist/engines/typedb/restore.js.map +1 -0
- package/dist/engines/typedb/version-maps.js +40 -0
- package/dist/engines/typedb/version-maps.js.map +1 -0
- package/dist/engines/typedb/version-validator.js +103 -0
- package/dist/engines/typedb/version-validator.js.map +1 -0
- package/dist/engines/valkey/backup.js +292 -0
- package/dist/engines/valkey/backup.js.map +1 -0
- package/dist/engines/valkey/binary-manager.js +33 -0
- package/dist/engines/valkey/binary-manager.js.map +1 -0
- package/dist/engines/valkey/binary-urls.js +98 -0
- package/dist/engines/valkey/binary-urls.js.map +1 -0
- package/dist/engines/valkey/cli-utils.js +38 -0
- package/dist/engines/valkey/cli-utils.js.map +1 -0
- package/dist/engines/valkey/hostdb-releases.js +21 -0
- package/dist/engines/valkey/hostdb-releases.js.map +1 -0
- package/dist/engines/valkey/index.js +1257 -0
- package/dist/engines/valkey/index.js.map +1 -0
- package/dist/engines/valkey/restore.js +340 -0
- package/dist/engines/valkey/restore.js.map +1 -0
- package/dist/engines/valkey/version-maps.js +70 -0
- package/dist/engines/valkey/version-maps.js.map +1 -0
- package/dist/engines/valkey/version-validator.js +112 -0
- package/dist/engines/valkey/version-validator.js.map +1 -0
- package/dist/engines/weaviate/api-client.js +50 -0
- package/dist/engines/weaviate/api-client.js.map +1 -0
- package/dist/engines/weaviate/backup.js +95 -0
- package/dist/engines/weaviate/backup.js.map +1 -0
- package/dist/engines/weaviate/binary-manager.js +58 -0
- package/dist/engines/weaviate/binary-manager.js.map +1 -0
- package/dist/engines/weaviate/binary-urls.js +92 -0
- package/dist/engines/weaviate/binary-urls.js.map +1 -0
- package/dist/engines/weaviate/cli-utils.js +39 -0
- package/dist/engines/weaviate/cli-utils.js.map +1 -0
- package/dist/engines/weaviate/hostdb-releases.js +21 -0
- package/dist/engines/weaviate/hostdb-releases.js.map +1 -0
- package/dist/engines/weaviate/index.js +871 -0
- package/dist/engines/weaviate/index.js.map +1 -0
- package/dist/engines/weaviate/restore.js +185 -0
- package/dist/engines/weaviate/restore.js.map +1 -0
- package/dist/engines/weaviate/version-maps.js +67 -0
- package/dist/engines/weaviate/version-maps.js.map +1 -0
- package/dist/engines/weaviate/version-validator.js +109 -0
- package/dist/engines/weaviate/version-validator.js.map +1 -0
- package/dist/types/index.js +102 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +12 -9
- package/bin/cli.js +0 -68
- package/cli/bin.ts +0 -10
- package/cli/commands/attach.ts +0 -139
- package/cli/commands/backup.ts +0 -290
- package/cli/commands/backups.ts +0 -247
- package/cli/commands/clone.ts +0 -159
- package/cli/commands/config.ts +0 -367
- package/cli/commands/connect.ts +0 -684
- package/cli/commands/create.ts +0 -1201
- package/cli/commands/databases.ts +0 -630
- package/cli/commands/delete.ts +0 -133
- package/cli/commands/deps.ts +0 -342
- package/cli/commands/detach.ts +0 -107
- package/cli/commands/doctor.ts +0 -689
- package/cli/commands/duckdb.ts +0 -273
- package/cli/commands/edit.ts +0 -683
- package/cli/commands/engines.ts +0 -1914
- package/cli/commands/export.ts +0 -544
- package/cli/commands/info.ts +0 -340
- package/cli/commands/list.ts +0 -284
- package/cli/commands/logs.ts +0 -102
- package/cli/commands/menu/backup-handlers.ts +0 -1571
- package/cli/commands/menu/container-handlers.ts +0 -2288
- package/cli/commands/menu/engine-handlers.ts +0 -355
- package/cli/commands/menu/index.ts +0 -342
- package/cli/commands/menu/settings-handlers.ts +0 -365
- package/cli/commands/menu/shared.ts +0 -23
- package/cli/commands/menu/shell-handlers.ts +0 -1811
- package/cli/commands/menu/sql-handlers.ts +0 -231
- package/cli/commands/menu/update-handlers.ts +0 -378
- package/cli/commands/menu/validators.ts +0 -8
- package/cli/commands/ports.ts +0 -211
- package/cli/commands/pull.ts +0 -223
- package/cli/commands/query.ts +0 -241
- package/cli/commands/restore.ts +0 -587
- package/cli/commands/run.ts +0 -178
- package/cli/commands/self-update.ts +0 -121
- package/cli/commands/sqlite.ts +0 -273
- package/cli/commands/start.ts +0 -218
- package/cli/commands/stop.ts +0 -241
- package/cli/commands/url.ts +0 -104
- package/cli/commands/users.ts +0 -264
- package/cli/commands/version.ts +0 -55
- package/cli/commands/which.ts +0 -290
- package/cli/constants.ts +0 -233
- package/cli/helpers.ts +0 -1593
- package/cli/index.ts +0 -162
- package/cli/ui/prompts.ts +0 -1525
- package/cli/ui/spinner.ts +0 -88
- package/cli/ui/theme.ts +0 -128
- package/cli/utils/file-follower.ts +0 -93
- package/config/backup-formats.ts +0 -446
- package/config/defaults.ts +0 -56
- package/config/engine-defaults.ts +0 -336
- package/config/engines-registry.ts +0 -150
- package/config/engines.schema.json +0 -135
- package/config/os-dependencies.ts +0 -888
- package/config/paths.ts +0 -200
- package/core/backup-restore.ts +0 -330
- package/core/base-binary-manager.ts +0 -562
- package/core/base-document-binary-manager.ts +0 -523
- package/core/base-embedded-binary-manager.ts +0 -547
- package/core/base-server-binary-manager.ts +0 -523
- package/core/config-manager.ts +0 -652
- package/core/container-manager.ts +0 -787
- package/core/credential-generator.ts +0 -93
- package/core/credential-manager.ts +0 -259
- package/core/dblab-utils.ts +0 -113
- package/core/dependency-manager.ts +0 -512
- package/core/docker-exporter.ts +0 -1345
- package/core/error-handler.ts +0 -419
- package/core/fs-error-utils.ts +0 -82
- package/core/homebrew-version-manager.ts +0 -352
- package/core/hostdb-client.ts +0 -344
- package/core/hostdb-metadata.ts +0 -350
- package/core/hostdb-releases-factory.ts +0 -237
- package/core/library-env.ts +0 -118
- package/core/pgweb-utils.ts +0 -62
- package/core/platform-service.ts +0 -829
- package/core/port-manager.ts +0 -165
- package/core/process-manager.ts +0 -576
- package/core/pull-manager.ts +0 -511
- package/core/query-parser.ts +0 -514
- package/core/spawn-utils.ts +0 -122
- package/core/start-with-retry.ts +0 -130
- package/core/test-cleanup.ts +0 -108
- package/core/tls-generator.ts +0 -116
- package/core/transaction-manager.ts +0 -158
- package/core/update-manager.ts +0 -308
- package/core/version-migration.ts +0 -346
- package/core/version-utils.ts +0 -104
- package/engines/base-engine.ts +0 -340
- package/engines/clickhouse/README.md +0 -231
- package/engines/clickhouse/backup.ts +0 -398
- package/engines/clickhouse/binary-manager.ts +0 -201
- package/engines/clickhouse/binary-urls.ts +0 -125
- package/engines/clickhouse/cli-utils.ts +0 -176
- package/engines/clickhouse/hostdb-releases.ts +0 -30
- package/engines/clickhouse/index.ts +0 -1345
- package/engines/clickhouse/restore.ts +0 -466
- package/engines/clickhouse/version-maps.ts +0 -95
- package/engines/clickhouse/version-validator.ts +0 -154
- package/engines/cockroachdb/README.md +0 -170
- package/engines/cockroachdb/backup.ts +0 -376
- package/engines/cockroachdb/binary-manager.ts +0 -45
- package/engines/cockroachdb/binary-urls.ts +0 -40
- package/engines/cockroachdb/cli-utils.ts +0 -384
- package/engines/cockroachdb/hostdb-releases.ts +0 -26
- package/engines/cockroachdb/index.ts +0 -1276
- package/engines/cockroachdb/restore.ts +0 -455
- package/engines/cockroachdb/version-maps.ts +0 -42
- package/engines/couchdb/README.md +0 -257
- package/engines/couchdb/api-client.ts +0 -81
- package/engines/couchdb/backup.ts +0 -137
- package/engines/couchdb/binary-manager.ts +0 -86
- package/engines/couchdb/binary-urls.ts +0 -115
- package/engines/couchdb/hostdb-releases.ts +0 -23
- package/engines/couchdb/index.ts +0 -1429
- package/engines/couchdb/restore.ts +0 -290
- package/engines/couchdb/version-maps.ts +0 -78
- package/engines/couchdb/version-validator.ts +0 -111
- package/engines/duckdb/README.md +0 -154
- package/engines/duckdb/binary-manager.ts +0 -45
- package/engines/duckdb/hostdb-releases.ts +0 -23
- package/engines/duckdb/index.ts +0 -749
- package/engines/duckdb/registry.ts +0 -303
- package/engines/duckdb/scanner.ts +0 -22
- package/engines/duckdb/version-maps.ts +0 -78
- package/engines/duckdb/version-validator.ts +0 -78
- package/engines/ferretdb/README.md +0 -262
- package/engines/ferretdb/backup.ts +0 -173
- package/engines/ferretdb/binary-manager.ts +0 -1095
- package/engines/ferretdb/binary-urls.ts +0 -183
- package/engines/ferretdb/index.ts +0 -1907
- package/engines/ferretdb/restore.ts +0 -357
- package/engines/file-based-utils.ts +0 -262
- package/engines/index.ts +0 -131
- package/engines/influxdb/README.md +0 -180
- package/engines/influxdb/api-client.ts +0 -64
- package/engines/influxdb/backup.ts +0 -160
- package/engines/influxdb/binary-manager.ts +0 -110
- package/engines/influxdb/binary-urls.ts +0 -69
- package/engines/influxdb/hostdb-releases.ts +0 -23
- package/engines/influxdb/index.ts +0 -1272
- package/engines/influxdb/restore.ts +0 -417
- package/engines/influxdb/version-maps.ts +0 -75
- package/engines/influxdb/version-validator.ts +0 -128
- package/engines/mariadb/README.md +0 -141
- package/engines/mariadb/backup.ts +0 -233
- package/engines/mariadb/binary-manager.ts +0 -45
- package/engines/mariadb/hostdb-releases.ts +0 -23
- package/engines/mariadb/index.ts +0 -1300
- package/engines/mariadb/restore.ts +0 -447
- package/engines/mariadb/version-maps.ts +0 -72
- package/engines/mariadb/version-validator.ts +0 -181
- package/engines/meilisearch/README.md +0 -255
- package/engines/meilisearch/api-client.ts +0 -61
- package/engines/meilisearch/backup.ts +0 -233
- package/engines/meilisearch/binary-manager.ts +0 -43
- package/engines/meilisearch/binary-urls.ts +0 -69
- package/engines/meilisearch/hostdb-releases.ts +0 -26
- package/engines/meilisearch/index.ts +0 -1292
- package/engines/meilisearch/restore.ts +0 -219
- package/engines/meilisearch/version-maps.ts +0 -78
- package/engines/meilisearch/version-validator.ts +0 -128
- package/engines/mongodb/README.md +0 -162
- package/engines/mongodb/backup.ts +0 -127
- package/engines/mongodb/binary-manager.ts +0 -48
- package/engines/mongodb/binary-urls.ts +0 -63
- package/engines/mongodb/cli-utils.ts +0 -171
- package/engines/mongodb/hostdb-releases.ts +0 -91
- package/engines/mongodb/index.ts +0 -1118
- package/engines/mongodb/restore.ts +0 -361
- package/engines/mongodb/version-maps.ts +0 -91
- package/engines/mongodb/version-validator.ts +0 -160
- package/engines/mysql/README.md +0 -142
- package/engines/mysql/backup.ts +0 -270
- package/engines/mysql/binary-detection.ts +0 -408
- package/engines/mysql/binary-manager.ts +0 -42
- package/engines/mysql/binary-urls.ts +0 -104
- package/engines/mysql/index.ts +0 -1361
- package/engines/mysql/restore.ts +0 -500
- package/engines/mysql/version-maps.ts +0 -91
- package/engines/mysql/version-validator.ts +0 -369
- package/engines/postgresql/README.md +0 -158
- package/engines/postgresql/backup.ts +0 -151
- package/engines/postgresql/binary-manager.ts +0 -114
- package/engines/postgresql/binary-urls.ts +0 -99
- package/engines/postgresql/hostdb-releases.ts +0 -26
- package/engines/postgresql/index.ts +0 -1143
- package/engines/postgresql/remote-version.ts +0 -161
- package/engines/postgresql/restore.ts +0 -342
- package/engines/postgresql/version-maps.ts +0 -83
- package/engines/postgresql/version-validator.ts +0 -413
- package/engines/qdrant/README.md +0 -222
- package/engines/qdrant/api-client.ts +0 -61
- package/engines/qdrant/backup.ts +0 -165
- package/engines/qdrant/binary-manager.ts +0 -43
- package/engines/qdrant/binary-urls.ts +0 -115
- package/engines/qdrant/cli-utils.ts +0 -43
- package/engines/qdrant/hostdb-releases.ts +0 -23
- package/engines/qdrant/index.ts +0 -1312
- package/engines/qdrant/restore.ts +0 -203
- package/engines/qdrant/version-maps.ts +0 -78
- package/engines/qdrant/version-validator.ts +0 -128
- package/engines/questdb/README.md +0 -334
- package/engines/questdb/backup.ts +0 -220
- package/engines/questdb/binary-manager.ts +0 -310
- package/engines/questdb/binary-urls.ts +0 -34
- package/engines/questdb/hostdb-releases.ts +0 -23
- package/engines/questdb/index.ts +0 -1023
- package/engines/questdb/restore.ts +0 -260
- package/engines/questdb/version-maps.ts +0 -37
- package/engines/questdb/version-validator.ts +0 -121
- package/engines/redis/README.md +0 -173
- package/engines/redis/backup.ts +0 -389
- package/engines/redis/binary-manager.ts +0 -44
- package/engines/redis/binary-urls.ts +0 -117
- package/engines/redis/cli-utils.ts +0 -42
- package/engines/redis/hostdb-releases.ts +0 -23
- package/engines/redis/index.ts +0 -1583
- package/engines/redis/restore.ts +0 -443
- package/engines/redis/version-maps.ts +0 -81
- package/engines/redis/version-validator.ts +0 -131
- package/engines/sqlite/README.md +0 -162
- package/engines/sqlite/binary-manager.ts +0 -52
- package/engines/sqlite/hostdb-releases.ts +0 -23
- package/engines/sqlite/index.ts +0 -641
- package/engines/sqlite/registry.ts +0 -198
- package/engines/sqlite/scanner.ts +0 -22
- package/engines/sqlite/version-maps.ts +0 -64
- package/engines/surrealdb/README.md +0 -218
- package/engines/surrealdb/backup.ts +0 -131
- package/engines/surrealdb/binary-manager.ts +0 -45
- package/engines/surrealdb/binary-urls.ts +0 -40
- package/engines/surrealdb/cli-utils.ts +0 -173
- package/engines/surrealdb/hostdb-releases.ts +0 -23
- package/engines/surrealdb/index.ts +0 -1246
- package/engines/surrealdb/restore.ts +0 -302
- package/engines/surrealdb/version-maps.ts +0 -41
- package/engines/tigerbeetle/README.md +0 -61
- package/engines/tigerbeetle/backup.ts +0 -49
- package/engines/tigerbeetle/binary-manager.ts +0 -95
- package/engines/tigerbeetle/binary-urls.ts +0 -62
- package/engines/tigerbeetle/hostdb-releases.ts +0 -26
- package/engines/tigerbeetle/index.ts +0 -746
- package/engines/tigerbeetle/restore.ts +0 -130
- package/engines/tigerbeetle/version-validator.ts +0 -126
- package/engines/typedb/backup.ts +0 -167
- package/engines/typedb/binary-manager.ts +0 -200
- package/engines/typedb/binary-urls.ts +0 -40
- package/engines/typedb/cli-utils.ts +0 -210
- package/engines/typedb/hostdb-releases.ts +0 -23
- package/engines/typedb/index.ts +0 -1275
- package/engines/typedb/restore.ts +0 -377
- package/engines/typedb/version-maps.ts +0 -48
- package/engines/typedb/version-validator.ts +0 -127
- package/engines/valkey/README.md +0 -219
- package/engines/valkey/backup.ts +0 -389
- package/engines/valkey/binary-manager.ts +0 -45
- package/engines/valkey/binary-urls.ts +0 -122
- package/engines/valkey/cli-utils.ts +0 -42
- package/engines/valkey/hostdb-releases.ts +0 -23
- package/engines/valkey/index.ts +0 -1585
- package/engines/valkey/restore.ts +0 -446
- package/engines/valkey/version-maps.ts +0 -81
- package/engines/valkey/version-validator.ts +0 -131
- package/engines/weaviate/README.md +0 -302
- package/engines/weaviate/api-client.ts +0 -61
- package/engines/weaviate/backup.ts +0 -145
- package/engines/weaviate/binary-manager.ts +0 -80
- package/engines/weaviate/binary-urls.ts +0 -115
- package/engines/weaviate/cli-utils.ts +0 -43
- package/engines/weaviate/hostdb-releases.ts +0 -23
- package/engines/weaviate/index.ts +0 -1139
- package/engines/weaviate/restore.ts +0 -235
- package/engines/weaviate/version-maps.ts +0 -78
- package/engines/weaviate/version-validator.ts +0 -128
- package/types/index.ts +0 -624
- /package/{config → dist/config}/engines.json +0 -0
|
@@ -1,1246 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SurrealDB Engine Implementation
|
|
3
|
-
*
|
|
4
|
-
* SurrealDB is a multi-model database that supports document, graph, and relational
|
|
5
|
-
* data models with a powerful query language (SurrealQL).
|
|
6
|
-
*
|
|
7
|
-
* Key characteristics:
|
|
8
|
-
* - Default HTTP port: 8000
|
|
9
|
-
* - Single binary: `surreal` (handles server, sql client, export, import)
|
|
10
|
-
* - Storage: SurrealKV (file-based) or RocksDB
|
|
11
|
-
* - Default user: `root` (password set on startup)
|
|
12
|
-
* - Hierarchy: Root > Namespace > Database
|
|
13
|
-
* - Query language: SurrealQL (SQL-like with graph traversal)
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { spawn, type SpawnOptions } from 'child_process'
|
|
17
|
-
import { existsSync } from 'fs'
|
|
18
|
-
import { mkdir, writeFile, unlink, stat, readdir } from 'fs/promises'
|
|
19
|
-
import { join } from 'path'
|
|
20
|
-
import { BaseEngine } from '../base-engine'
|
|
21
|
-
import { paths } from '../../config/paths'
|
|
22
|
-
import { getEngineDefaults } from '../../config/defaults'
|
|
23
|
-
import { platformService } from '../../core/platform-service'
|
|
24
|
-
import { configManager } from '../../core/config-manager'
|
|
25
|
-
import {
|
|
26
|
-
logDebug,
|
|
27
|
-
logWarning,
|
|
28
|
-
assertValidUsername,
|
|
29
|
-
} from '../../core/error-handler'
|
|
30
|
-
import { processManager } from '../../core/process-manager'
|
|
31
|
-
import { surrealdbBinaryManager } from './binary-manager'
|
|
32
|
-
import { getBinaryUrl } from './binary-urls'
|
|
33
|
-
import {
|
|
34
|
-
normalizeVersion,
|
|
35
|
-
SUPPORTED_MAJOR_VERSIONS,
|
|
36
|
-
SURREALDB_VERSION_MAP,
|
|
37
|
-
} from './version-maps'
|
|
38
|
-
import { fetchAvailableVersions as fetchHostdbVersions } from './hostdb-releases'
|
|
39
|
-
import {
|
|
40
|
-
detectBackupFormat as detectBackupFormatImpl,
|
|
41
|
-
restoreBackup,
|
|
42
|
-
} from './restore'
|
|
43
|
-
import { createBackup } from './backup'
|
|
44
|
-
import { validateSurrealIdentifier, escapeSurrealIdentifier } from './cli-utils'
|
|
45
|
-
import {
|
|
46
|
-
type Platform,
|
|
47
|
-
type Arch,
|
|
48
|
-
type ContainerConfig,
|
|
49
|
-
type ProgressCallback,
|
|
50
|
-
type BackupFormat,
|
|
51
|
-
type BackupOptions,
|
|
52
|
-
type BackupResult,
|
|
53
|
-
type RestoreResult,
|
|
54
|
-
type DumpResult,
|
|
55
|
-
type StatusResult,
|
|
56
|
-
type QueryResult,
|
|
57
|
-
type QueryOptions,
|
|
58
|
-
type CreateUserOptions,
|
|
59
|
-
type UserCredentials,
|
|
60
|
-
} from '../../types'
|
|
61
|
-
import { parseSurrealDBResult } from '../../core/query-parser'
|
|
62
|
-
|
|
63
|
-
const ENGINE = 'surrealdb'
|
|
64
|
-
const engineDef = getEngineDefaults(ENGINE)
|
|
65
|
-
|
|
66
|
-
export class SurrealDBEngine extends BaseEngine {
|
|
67
|
-
name = ENGINE
|
|
68
|
-
displayName = 'SurrealDB'
|
|
69
|
-
defaultPort = engineDef.defaultPort
|
|
70
|
-
supportedVersions = SUPPORTED_MAJOR_VERSIONS
|
|
71
|
-
|
|
72
|
-
// Get platform info for binary operations
|
|
73
|
-
getPlatformInfo(): { platform: Platform; arch: Arch } {
|
|
74
|
-
return platformService.getPlatformInfo()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Fetch available versions from hostdb (dynamically or from cache/fallback)
|
|
78
|
-
async fetchAvailableVersions(): Promise<Record<string, string[]>> {
|
|
79
|
-
return fetchHostdbVersions()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Get binary download URL from hostdb
|
|
83
|
-
getBinaryUrl(version: string, platform: Platform, arch: Arch): string {
|
|
84
|
-
return getBinaryUrl(version, platform, arch)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Resolves version string to full version (e.g., '2' -> '2.3.2')
|
|
88
|
-
resolveFullVersion(version: string): string {
|
|
89
|
-
if (/^\d+\.\d+\.\d+$/.test(version)) {
|
|
90
|
-
return version
|
|
91
|
-
}
|
|
92
|
-
return SURREALDB_VERSION_MAP[version] || version
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Get the path where binaries for a version would be installed
|
|
96
|
-
getBinaryPath(version: string): string {
|
|
97
|
-
const fullVersion = this.resolveFullVersion(version)
|
|
98
|
-
const { platform: p, arch: a } = this.getPlatformInfo()
|
|
99
|
-
return paths.getBinaryPath({
|
|
100
|
-
engine: 'surrealdb',
|
|
101
|
-
version: fullVersion,
|
|
102
|
-
platform: p,
|
|
103
|
-
arch: a,
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Verify that SurrealDB binaries are available
|
|
108
|
-
async verifyBinary(binPath: string): Promise<boolean> {
|
|
109
|
-
const ext = platformService.getExecutableExtension()
|
|
110
|
-
const surrealPath = join(binPath, 'bin', `surreal${ext}`)
|
|
111
|
-
return existsSync(surrealPath)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Check if a specific SurrealDB version is installed (downloaded)
|
|
115
|
-
async isBinaryInstalled(version: string): Promise<boolean> {
|
|
116
|
-
const { platform, arch } = this.getPlatformInfo()
|
|
117
|
-
return surrealdbBinaryManager.isInstalled(version, platform, arch)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Ensure SurrealDB binaries are available for a specific version
|
|
122
|
-
* Downloads from hostdb if not already installed
|
|
123
|
-
* Returns the path to the bin directory
|
|
124
|
-
*/
|
|
125
|
-
async ensureBinaries(
|
|
126
|
-
version: string,
|
|
127
|
-
onProgress?: ProgressCallback,
|
|
128
|
-
): Promise<string> {
|
|
129
|
-
const { platform, arch } = this.getPlatformInfo()
|
|
130
|
-
|
|
131
|
-
const binPath = await surrealdbBinaryManager.ensureInstalled(
|
|
132
|
-
version,
|
|
133
|
-
platform,
|
|
134
|
-
arch,
|
|
135
|
-
onProgress,
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
// Register binary in config
|
|
139
|
-
const ext = platformService.getExecutableExtension()
|
|
140
|
-
const surrealPath = join(binPath, 'bin', `surreal${ext}`)
|
|
141
|
-
if (existsSync(surrealPath)) {
|
|
142
|
-
await configManager.setBinaryPath('surreal', surrealPath, 'bundled')
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return binPath
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Initialize a new SurrealDB data directory
|
|
150
|
-
* Creates the directory structure for SurrealDB's storage
|
|
151
|
-
*/
|
|
152
|
-
async initDataDir(
|
|
153
|
-
containerName: string,
|
|
154
|
-
_version: string,
|
|
155
|
-
_options: Record<string, unknown> = {},
|
|
156
|
-
): Promise<string> {
|
|
157
|
-
const dataDir = paths.getContainerDataPath(containerName, {
|
|
158
|
-
engine: ENGINE,
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
// Create data directory
|
|
162
|
-
await mkdir(dataDir, { recursive: true })
|
|
163
|
-
|
|
164
|
-
logDebug(`Created SurrealDB data directory: ${dataDir}`)
|
|
165
|
-
|
|
166
|
-
return dataDir
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Get the path to surreal binary for a version
|
|
170
|
-
async getSurrealPath(version: string): Promise<string> {
|
|
171
|
-
const { platform, arch } = this.getPlatformInfo()
|
|
172
|
-
const fullVersion = normalizeVersion(version)
|
|
173
|
-
const ext = platformService.getExecutableExtension()
|
|
174
|
-
|
|
175
|
-
const binPath = paths.getBinaryPath({
|
|
176
|
-
engine: 'surrealdb',
|
|
177
|
-
version: fullVersion,
|
|
178
|
-
platform,
|
|
179
|
-
arch,
|
|
180
|
-
})
|
|
181
|
-
const surrealPath = join(binPath, 'bin', `surreal${ext}`)
|
|
182
|
-
|
|
183
|
-
if (existsSync(surrealPath)) {
|
|
184
|
-
return surrealPath
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
throw new Error(
|
|
188
|
-
`SurrealDB ${version} is not installed. Run: spindb engines download surrealdb ${version}`,
|
|
189
|
-
)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Start SurrealDB server
|
|
194
|
-
*/
|
|
195
|
-
async start(
|
|
196
|
-
container: ContainerConfig,
|
|
197
|
-
onProgress?: ProgressCallback,
|
|
198
|
-
): Promise<{ port: number; connectionString: string }> {
|
|
199
|
-
const { name, port, version, binaryPath } = container
|
|
200
|
-
|
|
201
|
-
// Check if already running
|
|
202
|
-
const alreadyRunning = await processManager.isRunning(name, {
|
|
203
|
-
engine: ENGINE,
|
|
204
|
-
})
|
|
205
|
-
if (alreadyRunning) {
|
|
206
|
-
return {
|
|
207
|
-
port,
|
|
208
|
-
connectionString: this.getConnectionString(container),
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Get SurrealDB binary path
|
|
213
|
-
let surrealBinary: string | null = null
|
|
214
|
-
const ext = platformService.getExecutableExtension()
|
|
215
|
-
|
|
216
|
-
if (binaryPath && existsSync(binaryPath)) {
|
|
217
|
-
const serverPath = join(binaryPath, 'bin', `surreal${ext}`)
|
|
218
|
-
if (existsSync(serverPath)) {
|
|
219
|
-
surrealBinary = serverPath
|
|
220
|
-
logDebug(`Using stored binary path: ${surrealBinary}`)
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (!surrealBinary) {
|
|
225
|
-
try {
|
|
226
|
-
surrealBinary = await this.getSurrealPath(version)
|
|
227
|
-
} catch (error) {
|
|
228
|
-
const originalMessage =
|
|
229
|
-
error instanceof Error ? error.message : String(error)
|
|
230
|
-
throw new Error(
|
|
231
|
-
`SurrealDB ${version} is not installed. Run: spindb engines download surrealdb ${version}\n` +
|
|
232
|
-
` Original error: ${originalMessage}`,
|
|
233
|
-
)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
238
|
-
const dataDir = paths.getContainerDataPath(name, { engine: ENGINE })
|
|
239
|
-
const pidFile = join(containerDir, 'surrealdb.pid')
|
|
240
|
-
|
|
241
|
-
onProgress?.({ stage: 'starting', message: 'Starting SurrealDB...' })
|
|
242
|
-
|
|
243
|
-
logDebug(`Starting SurrealDB with data dir: ${dataDir}`)
|
|
244
|
-
|
|
245
|
-
// SurrealDB start command
|
|
246
|
-
// Using SurrealKV for file-based storage
|
|
247
|
-
// Setting root credentials for authentication
|
|
248
|
-
const args = [
|
|
249
|
-
'start',
|
|
250
|
-
`surrealkv://${dataDir}`,
|
|
251
|
-
'--bind',
|
|
252
|
-
`127.0.0.1:${port}`,
|
|
253
|
-
'--user',
|
|
254
|
-
'root',
|
|
255
|
-
'--pass',
|
|
256
|
-
'root',
|
|
257
|
-
'--log',
|
|
258
|
-
'warn',
|
|
259
|
-
]
|
|
260
|
-
|
|
261
|
-
// Spawn the server process
|
|
262
|
-
// SurrealDB doesn't have a --background flag, so we detach it manually
|
|
263
|
-
// Set cwd to container directory so history.txt goes there instead of user's cwd
|
|
264
|
-
// Use 'ignore' for all stdio to prevent pipes from keeping the event loop alive
|
|
265
|
-
const proc = spawn(surrealBinary!, args, {
|
|
266
|
-
stdio: ['ignore', 'ignore', 'ignore'],
|
|
267
|
-
detached: true,
|
|
268
|
-
cwd: containerDir,
|
|
269
|
-
// On Windows, hide the console window to prevent it from blocking
|
|
270
|
-
windowsHide: true,
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
// Wait for the process to spawn
|
|
274
|
-
// On Windows, the 'spawn' event doesn't fire reliably with detached processes,
|
|
275
|
-
// so we write the PID file immediately and use a fixed delay.
|
|
276
|
-
// On Unix, we wait for the spawn event for more reliable startup detection.
|
|
277
|
-
const isWindows = process.platform === 'win32'
|
|
278
|
-
if (isWindows) {
|
|
279
|
-
// Add error handler and write PID file on Windows
|
|
280
|
-
await new Promise<void>((resolve, reject) => {
|
|
281
|
-
proc.on('error', (err) => {
|
|
282
|
-
logDebug(`SurrealDB spawn error on Windows: ${err.message}`)
|
|
283
|
-
reject(new Error(`Failed to spawn SurrealDB: ${err.message}`))
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
// Write PID file immediately on Windows
|
|
287
|
-
if (proc.pid) {
|
|
288
|
-
writeFile(pidFile, proc.pid.toString(), 'utf-8')
|
|
289
|
-
.then(() => {
|
|
290
|
-
logDebug(`Windows: wrote PID file ${pidFile} (pid: ${proc.pid})`)
|
|
291
|
-
proc.unref()
|
|
292
|
-
logDebug(
|
|
293
|
-
`Windows: waiting fixed delay for SurrealDB to start (pid: ${proc.pid})`,
|
|
294
|
-
)
|
|
295
|
-
setTimeout(resolve, 3000)
|
|
296
|
-
})
|
|
297
|
-
.catch((err) => {
|
|
298
|
-
// PID file write failed - clean up and reject
|
|
299
|
-
const errMsg = `Failed to write PID file: ${err instanceof Error ? err.message : String(err)}`
|
|
300
|
-
logDebug(errMsg)
|
|
301
|
-
// Kill the spawned process since we can't track it
|
|
302
|
-
try {
|
|
303
|
-
if (proc.pid) process.kill(proc.pid, 'SIGTERM')
|
|
304
|
-
} catch {
|
|
305
|
-
// Process may have already exited
|
|
306
|
-
}
|
|
307
|
-
reject(new Error(errMsg))
|
|
308
|
-
})
|
|
309
|
-
} else {
|
|
310
|
-
reject(new Error('Failed to spawn SurrealDB: no PID available'))
|
|
311
|
-
}
|
|
312
|
-
})
|
|
313
|
-
} else {
|
|
314
|
-
const spawnTimeout = 30000
|
|
315
|
-
await new Promise<void>((resolve, reject) => {
|
|
316
|
-
const timeoutId = setTimeout(() => {
|
|
317
|
-
reject(
|
|
318
|
-
new Error(
|
|
319
|
-
`SurrealDB process failed to spawn within ${spawnTimeout}ms`,
|
|
320
|
-
),
|
|
321
|
-
)
|
|
322
|
-
}, spawnTimeout)
|
|
323
|
-
|
|
324
|
-
proc.on('error', (err) => {
|
|
325
|
-
clearTimeout(timeoutId)
|
|
326
|
-
logDebug(`SurrealDB spawn error: ${err.message}`)
|
|
327
|
-
reject(new Error(`Failed to spawn SurrealDB: ${err.message}`))
|
|
328
|
-
})
|
|
329
|
-
|
|
330
|
-
// Capture early exit (process dies before spawn event)
|
|
331
|
-
proc.on('close', (code, signal) => {
|
|
332
|
-
clearTimeout(timeoutId)
|
|
333
|
-
const errMsg = `SurrealDB process exited early (code: ${code}, signal: ${signal})`
|
|
334
|
-
logDebug(errMsg)
|
|
335
|
-
reject(new Error(errMsg))
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
proc.on('spawn', async () => {
|
|
339
|
-
clearTimeout(timeoutId)
|
|
340
|
-
logDebug(`SurrealDB process spawned (pid: ${proc.pid})`)
|
|
341
|
-
|
|
342
|
-
// Remove the early exit handler since we spawned successfully
|
|
343
|
-
proc.removeAllListeners('close')
|
|
344
|
-
|
|
345
|
-
// Write PID file after successful spawn
|
|
346
|
-
if (proc.pid) {
|
|
347
|
-
try {
|
|
348
|
-
await writeFile(pidFile, proc.pid.toString(), 'utf-8')
|
|
349
|
-
} catch (err) {
|
|
350
|
-
// PID file write failed - clean up and reject
|
|
351
|
-
const errMsg = `Failed to write PID file: ${err instanceof Error ? err.message : String(err)}`
|
|
352
|
-
logDebug(errMsg)
|
|
353
|
-
|
|
354
|
-
// Kill the spawned process since we can't track it
|
|
355
|
-
try {
|
|
356
|
-
process.kill(proc.pid, 'SIGTERM')
|
|
357
|
-
} catch {
|
|
358
|
-
// Process may have already exited, ignore
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// Remove partial PID file if it exists
|
|
362
|
-
try {
|
|
363
|
-
await unlink(pidFile)
|
|
364
|
-
} catch {
|
|
365
|
-
// Ignore cleanup errors (file may not exist)
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
reject(new Error(errMsg))
|
|
369
|
-
return
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// Unref the process so it can run independently
|
|
374
|
-
proc.unref()
|
|
375
|
-
|
|
376
|
-
// Give the server a moment to initialize
|
|
377
|
-
setTimeout(resolve, 500)
|
|
378
|
-
})
|
|
379
|
-
})
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// Wait for server to be ready
|
|
383
|
-
logDebug(`Waiting for SurrealDB server to be ready on port ${port}...`)
|
|
384
|
-
const ready = await this.waitForReady(port, version)
|
|
385
|
-
logDebug(`waitForReady returned: ${ready}`)
|
|
386
|
-
|
|
387
|
-
if (!ready) {
|
|
388
|
-
throw new Error(
|
|
389
|
-
`SurrealDB failed to start within timeout. Container: ${name}`,
|
|
390
|
-
)
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return {
|
|
394
|
-
port,
|
|
395
|
-
connectionString: this.getConnectionString(container),
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// Wait for SurrealDB to be ready using surreal isready
|
|
400
|
-
private async waitForReady(
|
|
401
|
-
port: number,
|
|
402
|
-
version: string,
|
|
403
|
-
timeoutMs = 60000,
|
|
404
|
-
): Promise<boolean> {
|
|
405
|
-
logDebug(`waitForReady called for port ${port}, version ${version}`)
|
|
406
|
-
const startTime = Date.now()
|
|
407
|
-
const checkInterval = 500
|
|
408
|
-
|
|
409
|
-
let surreal: string
|
|
410
|
-
try {
|
|
411
|
-
logDebug('Getting surreal binary path...')
|
|
412
|
-
surreal = await this.getSurrealPath(version)
|
|
413
|
-
logDebug(`Got surreal binary path: ${surreal}`)
|
|
414
|
-
} catch (err) {
|
|
415
|
-
logDebug(`Error getting surreal binary path: ${err}`)
|
|
416
|
-
logWarning('SurrealDB binary not found, cannot verify server is ready.')
|
|
417
|
-
return false
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
logDebug(`Starting connection loop, timeout: ${timeoutMs}ms`)
|
|
421
|
-
let attempt = 0
|
|
422
|
-
const perAttemptTimeout = 5000 // 5 second timeout per isready attempt
|
|
423
|
-
while (Date.now() - startTime < timeoutMs) {
|
|
424
|
-
attempt++
|
|
425
|
-
logDebug(`Connection attempt ${attempt}...`)
|
|
426
|
-
try {
|
|
427
|
-
const args = ['isready', '--endpoint', `http://127.0.0.1:${port}`]
|
|
428
|
-
await new Promise<void>((resolve, reject) => {
|
|
429
|
-
let stderrOutput = ''
|
|
430
|
-
const proc = spawn(surreal, args, {
|
|
431
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
432
|
-
})
|
|
433
|
-
|
|
434
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
435
|
-
stderrOutput += data.toString()
|
|
436
|
-
})
|
|
437
|
-
|
|
438
|
-
// Timeout for this specific attempt - kill process if it hangs
|
|
439
|
-
const attemptTimer = setTimeout(() => {
|
|
440
|
-
logDebug(
|
|
441
|
-
`isready attempt ${attempt} timed out after ${perAttemptTimeout}ms`,
|
|
442
|
-
)
|
|
443
|
-
proc.kill('SIGKILL')
|
|
444
|
-
reject(new Error('isready timeout'))
|
|
445
|
-
}, perAttemptTimeout)
|
|
446
|
-
|
|
447
|
-
proc.on('close', (code) => {
|
|
448
|
-
clearTimeout(attemptTimer)
|
|
449
|
-
logDebug(`isready process closed with code ${code}`)
|
|
450
|
-
if (code === 0) resolve()
|
|
451
|
-
else {
|
|
452
|
-
// Log non-zero exit for debugging
|
|
453
|
-
if (attempt <= 3 || attempt % 10 === 0) {
|
|
454
|
-
logDebug(
|
|
455
|
-
`isready attempt ${attempt} failed (code: ${code})${stderrOutput ? `: ${stderrOutput.trim()}` : ''}`,
|
|
456
|
-
)
|
|
457
|
-
}
|
|
458
|
-
reject(new Error(`Exit code ${code}`))
|
|
459
|
-
}
|
|
460
|
-
})
|
|
461
|
-
proc.on('error', (err) => {
|
|
462
|
-
clearTimeout(attemptTimer)
|
|
463
|
-
logDebug(`isready error: ${err}`)
|
|
464
|
-
reject(err)
|
|
465
|
-
})
|
|
466
|
-
})
|
|
467
|
-
logDebug(`SurrealDB ready on port ${port}`)
|
|
468
|
-
return true
|
|
469
|
-
} catch (err) {
|
|
470
|
-
logDebug(`Attempt ${attempt} failed: ${err}`)
|
|
471
|
-
await new Promise((resolve) => setTimeout(resolve, checkInterval))
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
logWarning(`SurrealDB did not become ready within ${timeoutMs}ms`)
|
|
476
|
-
return false
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Stop SurrealDB server
|
|
481
|
-
*/
|
|
482
|
-
async stop(container: ContainerConfig): Promise<void> {
|
|
483
|
-
const { name, port } = container
|
|
484
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
485
|
-
const pidFile = join(containerDir, 'surrealdb.pid')
|
|
486
|
-
|
|
487
|
-
logDebug(`Stopping SurrealDB container "${name}" on port ${port}`)
|
|
488
|
-
|
|
489
|
-
// Find PID by checking the process using cross-platform helper
|
|
490
|
-
let pid: number | null = null
|
|
491
|
-
|
|
492
|
-
// Try to find SurrealDB process by port
|
|
493
|
-
try {
|
|
494
|
-
const pids = await platformService.findProcessByPort(port)
|
|
495
|
-
if (pids.length > 0) {
|
|
496
|
-
pid = pids[0]
|
|
497
|
-
}
|
|
498
|
-
} catch {
|
|
499
|
-
// Ignore
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// Kill process if found
|
|
503
|
-
if (pid && platformService.isProcessRunning(pid)) {
|
|
504
|
-
logDebug(`Killing SurrealDB process ${pid}`)
|
|
505
|
-
try {
|
|
506
|
-
await platformService.terminateProcess(pid, false)
|
|
507
|
-
// Wait for graceful termination
|
|
508
|
-
// On Windows, SurrealDB's SurrealKV uses memory-mapped files that
|
|
509
|
-
// take longer to release, so we wait longer to avoid EBUSY errors
|
|
510
|
-
const gracefulWait = process.platform === 'win32' ? 5000 : 2000
|
|
511
|
-
await new Promise((resolve) => setTimeout(resolve, gracefulWait))
|
|
512
|
-
|
|
513
|
-
if (platformService.isProcessRunning(pid)) {
|
|
514
|
-
logWarning(`Graceful termination failed, force killing ${pid}`)
|
|
515
|
-
await platformService.terminateProcess(pid, true)
|
|
516
|
-
// Additional wait after force kill on Windows for file handle release
|
|
517
|
-
if (process.platform === 'win32') {
|
|
518
|
-
await new Promise((resolve) => setTimeout(resolve, 3000))
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
} catch (error) {
|
|
522
|
-
logDebug(`Process termination error: ${error}`)
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
// Cleanup PID file
|
|
527
|
-
if (existsSync(pidFile)) {
|
|
528
|
-
try {
|
|
529
|
-
await unlink(pidFile)
|
|
530
|
-
} catch {
|
|
531
|
-
// Ignore
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
logDebug('SurrealDB stopped')
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// Get SurrealDB server status
|
|
539
|
-
async status(container: ContainerConfig): Promise<StatusResult> {
|
|
540
|
-
const { port, version } = container
|
|
541
|
-
|
|
542
|
-
// Try to connect using surreal isready
|
|
543
|
-
try {
|
|
544
|
-
const surreal = await this.getSurrealPath(version)
|
|
545
|
-
const args = ['isready', '--endpoint', `http://127.0.0.1:${port}`]
|
|
546
|
-
await new Promise<void>((resolve, reject) => {
|
|
547
|
-
const proc = spawn(surreal, args, {
|
|
548
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
549
|
-
})
|
|
550
|
-
proc.on('close', (code) => {
|
|
551
|
-
if (code === 0) resolve()
|
|
552
|
-
else reject(new Error(`Exit code ${code}`))
|
|
553
|
-
})
|
|
554
|
-
proc.on('error', reject)
|
|
555
|
-
})
|
|
556
|
-
return { running: true, message: 'SurrealDB is running' }
|
|
557
|
-
} catch {
|
|
558
|
-
return { running: false, message: 'SurrealDB is not running' }
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// Detect backup format
|
|
563
|
-
async detectBackupFormat(filePath: string): Promise<BackupFormat> {
|
|
564
|
-
return detectBackupFormatImpl(filePath)
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Restore a backup
|
|
569
|
-
*/
|
|
570
|
-
async restore(
|
|
571
|
-
container: ContainerConfig,
|
|
572
|
-
backupPath: string,
|
|
573
|
-
options: { database?: string } = {},
|
|
574
|
-
): Promise<RestoreResult> {
|
|
575
|
-
const { name, port, version } = container
|
|
576
|
-
|
|
577
|
-
return restoreBackup(backupPath, {
|
|
578
|
-
containerName: name,
|
|
579
|
-
port,
|
|
580
|
-
database: options.database || container.database || 'default',
|
|
581
|
-
version,
|
|
582
|
-
})
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* Get connection string
|
|
587
|
-
* Format: ws://127.0.0.1:PORT or http://127.0.0.1:PORT
|
|
588
|
-
*/
|
|
589
|
-
getConnectionString(container: ContainerConfig, _database?: string): string {
|
|
590
|
-
const { port } = container
|
|
591
|
-
// SurrealDB WebSocket connection - namespace/database specified in queries
|
|
592
|
-
return `ws://127.0.0.1:${port}/rpc`
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
// Open surreal sql interactive shell
|
|
596
|
-
async connect(container: ContainerConfig, database?: string): Promise<void> {
|
|
597
|
-
const { port, version, name } = container
|
|
598
|
-
const db = database || container.database || 'default'
|
|
599
|
-
const namespace = name.replace(/-/g, '_')
|
|
600
|
-
|
|
601
|
-
const surreal = await this.getSurrealPath(version)
|
|
602
|
-
|
|
603
|
-
// Use container directory as cwd so history.txt is written there, not user's cwd
|
|
604
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
605
|
-
|
|
606
|
-
const spawnOptions: SpawnOptions = {
|
|
607
|
-
stdio: 'inherit',
|
|
608
|
-
cwd: containerDir,
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
return new Promise((resolve, reject) => {
|
|
612
|
-
const proc = spawn(
|
|
613
|
-
surreal,
|
|
614
|
-
[
|
|
615
|
-
'sql',
|
|
616
|
-
'--endpoint',
|
|
617
|
-
`ws://127.0.0.1:${port}`,
|
|
618
|
-
'--user',
|
|
619
|
-
'root',
|
|
620
|
-
'--pass',
|
|
621
|
-
'root',
|
|
622
|
-
'--ns',
|
|
623
|
-
namespace,
|
|
624
|
-
'--db',
|
|
625
|
-
db,
|
|
626
|
-
'--pretty',
|
|
627
|
-
],
|
|
628
|
-
spawnOptions,
|
|
629
|
-
)
|
|
630
|
-
|
|
631
|
-
proc.on('error', reject)
|
|
632
|
-
proc.on('close', () => resolve())
|
|
633
|
-
})
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Create a new database
|
|
638
|
-
* In SurrealDB, databases are created implicitly when accessed
|
|
639
|
-
* But we can ensure it exists by defining it
|
|
640
|
-
*/
|
|
641
|
-
async createDatabase(
|
|
642
|
-
container: ContainerConfig,
|
|
643
|
-
database: string,
|
|
644
|
-
): Promise<void> {
|
|
645
|
-
const { port, version, name } = container
|
|
646
|
-
const namespace = name.replace(/-/g, '_')
|
|
647
|
-
|
|
648
|
-
// Validate database identifier to prevent injection
|
|
649
|
-
validateSurrealIdentifier(database, 'database')
|
|
650
|
-
|
|
651
|
-
const surreal = await this.getSurrealPath(version)
|
|
652
|
-
|
|
653
|
-
// Use container directory as cwd so history.txt is written there, not user's cwd
|
|
654
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
655
|
-
|
|
656
|
-
// SurrealDB creates databases implicitly, but we'll use USE to ensure it exists
|
|
657
|
-
const args = [
|
|
658
|
-
'sql',
|
|
659
|
-
'--endpoint',
|
|
660
|
-
`ws://127.0.0.1:${port}`,
|
|
661
|
-
'--user',
|
|
662
|
-
'root',
|
|
663
|
-
'--pass',
|
|
664
|
-
'root',
|
|
665
|
-
'--ns',
|
|
666
|
-
namespace,
|
|
667
|
-
'--db',
|
|
668
|
-
database,
|
|
669
|
-
'--hide-welcome',
|
|
670
|
-
]
|
|
671
|
-
|
|
672
|
-
await new Promise<void>((resolve, reject) => {
|
|
673
|
-
const proc = spawn(surreal, args, {
|
|
674
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
675
|
-
cwd: containerDir,
|
|
676
|
-
})
|
|
677
|
-
|
|
678
|
-
let stderr = ''
|
|
679
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
680
|
-
stderr += data.toString()
|
|
681
|
-
})
|
|
682
|
-
|
|
683
|
-
// Send a simple query to ensure namespace/database context is created
|
|
684
|
-
proc.stdin?.write('INFO FOR DB;\n')
|
|
685
|
-
proc.stdin?.end()
|
|
686
|
-
|
|
687
|
-
proc.on('close', (code) => {
|
|
688
|
-
if (code === 0) {
|
|
689
|
-
logDebug(`Created SurrealDB database: ${database}`)
|
|
690
|
-
resolve()
|
|
691
|
-
} else {
|
|
692
|
-
reject(new Error(`Failed to create database: ${stderr}`))
|
|
693
|
-
}
|
|
694
|
-
})
|
|
695
|
-
proc.on('error', reject)
|
|
696
|
-
})
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
* Drop a database
|
|
701
|
-
*/
|
|
702
|
-
async dropDatabase(
|
|
703
|
-
container: ContainerConfig,
|
|
704
|
-
database: string,
|
|
705
|
-
): Promise<void> {
|
|
706
|
-
const { port, version, name } = container
|
|
707
|
-
const namespace = name.replace(/-/g, '_')
|
|
708
|
-
|
|
709
|
-
// Don't allow dropping default database
|
|
710
|
-
if (database === 'default') {
|
|
711
|
-
throw new Error('Cannot drop the default database')
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
// Validate database identifier to prevent injection
|
|
715
|
-
validateSurrealIdentifier(database, 'database')
|
|
716
|
-
const escapedDb = escapeSurrealIdentifier(database)
|
|
717
|
-
|
|
718
|
-
const surreal = await this.getSurrealPath(version)
|
|
719
|
-
|
|
720
|
-
// Use container directory as cwd so history.txt is written there, not user's cwd
|
|
721
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
722
|
-
|
|
723
|
-
const args = [
|
|
724
|
-
'sql',
|
|
725
|
-
'--endpoint',
|
|
726
|
-
`ws://127.0.0.1:${port}`,
|
|
727
|
-
'--user',
|
|
728
|
-
'root',
|
|
729
|
-
'--pass',
|
|
730
|
-
'root',
|
|
731
|
-
'--ns',
|
|
732
|
-
namespace,
|
|
733
|
-
'--hide-welcome',
|
|
734
|
-
]
|
|
735
|
-
|
|
736
|
-
await new Promise<void>((resolve, reject) => {
|
|
737
|
-
const proc = spawn(surreal, args, {
|
|
738
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
739
|
-
cwd: containerDir,
|
|
740
|
-
})
|
|
741
|
-
|
|
742
|
-
let stderr = ''
|
|
743
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
744
|
-
stderr += data.toString()
|
|
745
|
-
})
|
|
746
|
-
|
|
747
|
-
// Remove database
|
|
748
|
-
proc.stdin?.write(`REMOVE DATABASE ${escapedDb};\n`)
|
|
749
|
-
proc.stdin?.end()
|
|
750
|
-
|
|
751
|
-
proc.on('close', (code) => {
|
|
752
|
-
if (code === 0) {
|
|
753
|
-
logDebug(`Dropped SurrealDB database: ${database}`)
|
|
754
|
-
resolve()
|
|
755
|
-
} else {
|
|
756
|
-
reject(new Error(`Failed to drop database: ${stderr}`))
|
|
757
|
-
}
|
|
758
|
-
})
|
|
759
|
-
proc.on('error', reject)
|
|
760
|
-
})
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
/**
|
|
764
|
-
* Get the database size in bytes
|
|
765
|
-
* SurrealDB doesn't have a direct size query, so we estimate from data directory
|
|
766
|
-
*/
|
|
767
|
-
async getDatabaseSize(container: ContainerConfig): Promise<number | null> {
|
|
768
|
-
const dataDir = paths.getContainerDataPath(container.name, {
|
|
769
|
-
engine: ENGINE,
|
|
770
|
-
})
|
|
771
|
-
|
|
772
|
-
try {
|
|
773
|
-
const stats = await stat(dataDir)
|
|
774
|
-
|
|
775
|
-
if (!stats.isDirectory()) {
|
|
776
|
-
return null
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
// Recursively calculate directory size
|
|
780
|
-
let totalSize = 0
|
|
781
|
-
const calculateSize = async (dir: string): Promise<void> => {
|
|
782
|
-
const entries = await readdir(dir, { withFileTypes: true })
|
|
783
|
-
for (const entry of entries) {
|
|
784
|
-
const fullPath = join(dir, entry.name)
|
|
785
|
-
if (entry.isDirectory()) {
|
|
786
|
-
await calculateSize(fullPath)
|
|
787
|
-
} else {
|
|
788
|
-
const fileStat = await stat(fullPath)
|
|
789
|
-
totalSize += fileStat.size
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
await calculateSize(dataDir)
|
|
795
|
-
return totalSize
|
|
796
|
-
} catch {
|
|
797
|
-
return null
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Dump from a remote SurrealDB connection
|
|
803
|
-
* Uses surreal export
|
|
804
|
-
*
|
|
805
|
-
* Connection string format: surrealdb://[user:password@]host[:port][/namespace/database]
|
|
806
|
-
*/
|
|
807
|
-
async dumpFromConnectionString(
|
|
808
|
-
connectionString: string,
|
|
809
|
-
outputPath: string,
|
|
810
|
-
): Promise<DumpResult> {
|
|
811
|
-
// Parse connection string
|
|
812
|
-
let url: URL
|
|
813
|
-
try {
|
|
814
|
-
url = new URL(connectionString)
|
|
815
|
-
} catch {
|
|
816
|
-
// Sanitize connection string to avoid leaking credentials in error messages
|
|
817
|
-
const sanitized = connectionString.replace(
|
|
818
|
-
/\/\/([^:]+):([^@]+)@/,
|
|
819
|
-
'//***:***@',
|
|
820
|
-
)
|
|
821
|
-
throw new Error(
|
|
822
|
-
`Invalid connection string: ${sanitized}\n` +
|
|
823
|
-
'Expected format: surrealdb://[user:password@]host[:port][/namespace/database]',
|
|
824
|
-
)
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
const host = url.hostname || '127.0.0.1'
|
|
828
|
-
const port = parseInt(url.port, 10) || 8000
|
|
829
|
-
const user = url.username || 'root'
|
|
830
|
-
const password = url.password || 'root'
|
|
831
|
-
|
|
832
|
-
// Parse namespace/database from path
|
|
833
|
-
const pathParts = url.pathname.split('/').filter(Boolean)
|
|
834
|
-
const namespace = pathParts[0] || 'test'
|
|
835
|
-
const database = pathParts[1] || 'test'
|
|
836
|
-
|
|
837
|
-
logDebug(
|
|
838
|
-
`Connecting to remote SurrealDB at ${host}:${port} (ns: ${namespace}, db: ${database})`,
|
|
839
|
-
)
|
|
840
|
-
|
|
841
|
-
// For remote dump, we need a local surreal binary
|
|
842
|
-
let surreal: string | null = null
|
|
843
|
-
const cached = await configManager.getBinaryPath('surreal')
|
|
844
|
-
if (cached && existsSync(cached)) {
|
|
845
|
-
surreal = cached
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
if (!surreal) {
|
|
849
|
-
throw new Error(
|
|
850
|
-
'SurrealDB binary not found. Run: spindb engines download surrealdb 2\n' +
|
|
851
|
-
'A local SurrealDB binary is needed to dump from remote connections.',
|
|
852
|
-
)
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
return new Promise<DumpResult>((resolve, reject) => {
|
|
856
|
-
const args = [
|
|
857
|
-
'export',
|
|
858
|
-
'--endpoint',
|
|
859
|
-
`http://${host}:${port}`,
|
|
860
|
-
'--user',
|
|
861
|
-
user,
|
|
862
|
-
'--pass',
|
|
863
|
-
password,
|
|
864
|
-
'--ns',
|
|
865
|
-
namespace,
|
|
866
|
-
'--db',
|
|
867
|
-
database,
|
|
868
|
-
outputPath,
|
|
869
|
-
]
|
|
870
|
-
|
|
871
|
-
const proc = spawn(surreal, args, {
|
|
872
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
873
|
-
})
|
|
874
|
-
|
|
875
|
-
let stdout = ''
|
|
876
|
-
let stderr = ''
|
|
877
|
-
|
|
878
|
-
proc.stdout.on('data', (data: Buffer) => {
|
|
879
|
-
stdout += data.toString()
|
|
880
|
-
})
|
|
881
|
-
proc.stderr.on('data', (data: Buffer) => {
|
|
882
|
-
stderr += data.toString()
|
|
883
|
-
})
|
|
884
|
-
|
|
885
|
-
proc.on('close', (code) => {
|
|
886
|
-
if (code === 0) {
|
|
887
|
-
resolve({
|
|
888
|
-
filePath: outputPath,
|
|
889
|
-
stdout,
|
|
890
|
-
stderr,
|
|
891
|
-
code: 0,
|
|
892
|
-
})
|
|
893
|
-
} else {
|
|
894
|
-
reject(new Error(stderr || `Exit code ${code}`))
|
|
895
|
-
}
|
|
896
|
-
})
|
|
897
|
-
proc.on('error', reject)
|
|
898
|
-
})
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
// Create a backup
|
|
902
|
-
async backup(
|
|
903
|
-
container: ContainerConfig,
|
|
904
|
-
outputPath: string,
|
|
905
|
-
options: BackupOptions,
|
|
906
|
-
): Promise<BackupResult> {
|
|
907
|
-
return createBackup(container, outputPath, options)
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
// Run a SurrealQL file or inline statement
|
|
911
|
-
async runScript(
|
|
912
|
-
container: ContainerConfig,
|
|
913
|
-
options: { file?: string; sql?: string; database?: string },
|
|
914
|
-
): Promise<void> {
|
|
915
|
-
const { port, version, name } = container
|
|
916
|
-
const db = options.database || container.database || 'default'
|
|
917
|
-
const namespace = name.replace(/-/g, '_')
|
|
918
|
-
|
|
919
|
-
const surreal = await this.getSurrealPath(version)
|
|
920
|
-
|
|
921
|
-
// Use container directory as cwd so history.txt is written there, not user's cwd
|
|
922
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
923
|
-
|
|
924
|
-
if (options.file) {
|
|
925
|
-
// Run SurrealQL file using import
|
|
926
|
-
const args = [
|
|
927
|
-
'import',
|
|
928
|
-
'--endpoint',
|
|
929
|
-
`http://127.0.0.1:${port}`,
|
|
930
|
-
'--user',
|
|
931
|
-
'root',
|
|
932
|
-
'--pass',
|
|
933
|
-
'root',
|
|
934
|
-
'--ns',
|
|
935
|
-
namespace,
|
|
936
|
-
'--db',
|
|
937
|
-
db,
|
|
938
|
-
options.file,
|
|
939
|
-
]
|
|
940
|
-
|
|
941
|
-
await new Promise<void>((resolve, reject) => {
|
|
942
|
-
const proc = spawn(surreal, args, {
|
|
943
|
-
stdio: 'inherit',
|
|
944
|
-
cwd: containerDir,
|
|
945
|
-
})
|
|
946
|
-
|
|
947
|
-
proc.on('error', reject)
|
|
948
|
-
proc.on('close', (code, signal) => {
|
|
949
|
-
if (code === 0) resolve()
|
|
950
|
-
else if (code === null)
|
|
951
|
-
reject(new Error(`surreal import was killed by signal ${signal}`))
|
|
952
|
-
else reject(new Error(`surreal import exited with code ${code}`))
|
|
953
|
-
})
|
|
954
|
-
})
|
|
955
|
-
} else if (options.sql) {
|
|
956
|
-
// Run inline SurrealQL via stdin
|
|
957
|
-
const args = [
|
|
958
|
-
'sql',
|
|
959
|
-
'--endpoint',
|
|
960
|
-
`ws://127.0.0.1:${port}`,
|
|
961
|
-
'--user',
|
|
962
|
-
'root',
|
|
963
|
-
'--pass',
|
|
964
|
-
'root',
|
|
965
|
-
'--ns',
|
|
966
|
-
namespace,
|
|
967
|
-
'--db',
|
|
968
|
-
db,
|
|
969
|
-
'--hide-welcome',
|
|
970
|
-
]
|
|
971
|
-
|
|
972
|
-
await new Promise<void>((resolve, reject) => {
|
|
973
|
-
const proc = spawn(surreal, args, {
|
|
974
|
-
stdio: ['pipe', 'inherit', 'inherit'],
|
|
975
|
-
cwd: containerDir,
|
|
976
|
-
})
|
|
977
|
-
|
|
978
|
-
proc.on('error', reject)
|
|
979
|
-
proc.on('close', (code, signal) => {
|
|
980
|
-
if (code === 0) resolve()
|
|
981
|
-
else if (code === null)
|
|
982
|
-
reject(new Error(`surreal sql was killed by signal ${signal}`))
|
|
983
|
-
else reject(new Error(`surreal sql exited with code ${code}`))
|
|
984
|
-
})
|
|
985
|
-
|
|
986
|
-
proc.stdin?.write(options.sql)
|
|
987
|
-
proc.stdin?.end()
|
|
988
|
-
})
|
|
989
|
-
} else {
|
|
990
|
-
throw new Error('Either file or sql option must be provided')
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
/**
|
|
995
|
-
* Execute a SurrealQL query and return structured results
|
|
996
|
-
*
|
|
997
|
-
* Examples:
|
|
998
|
-
* SELECT * FROM users
|
|
999
|
-
* SELECT * FROM users WHERE active = true
|
|
1000
|
-
*/
|
|
1001
|
-
async executeQuery(
|
|
1002
|
-
container: ContainerConfig,
|
|
1003
|
-
query: string,
|
|
1004
|
-
options?: QueryOptions,
|
|
1005
|
-
): Promise<QueryResult> {
|
|
1006
|
-
const { port, version, name } = container
|
|
1007
|
-
const db = options?.database || container.database || 'default'
|
|
1008
|
-
const namespace = name.replace(/-/g, '_')
|
|
1009
|
-
|
|
1010
|
-
const surreal = await this.getSurrealPath(version)
|
|
1011
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
1012
|
-
|
|
1013
|
-
return new Promise((resolve, reject) => {
|
|
1014
|
-
const args = [
|
|
1015
|
-
'sql',
|
|
1016
|
-
'--endpoint',
|
|
1017
|
-
`ws://127.0.0.1:${port}`,
|
|
1018
|
-
'--user',
|
|
1019
|
-
'root',
|
|
1020
|
-
'--pass',
|
|
1021
|
-
'root',
|
|
1022
|
-
'--ns',
|
|
1023
|
-
namespace,
|
|
1024
|
-
'--db',
|
|
1025
|
-
db,
|
|
1026
|
-
'--hide-welcome',
|
|
1027
|
-
'--json',
|
|
1028
|
-
]
|
|
1029
|
-
|
|
1030
|
-
const proc = spawn(surreal, args, {
|
|
1031
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1032
|
-
cwd: containerDir,
|
|
1033
|
-
})
|
|
1034
|
-
|
|
1035
|
-
let stdout = ''
|
|
1036
|
-
let stderr = ''
|
|
1037
|
-
|
|
1038
|
-
proc.stdout?.on('data', (data: Buffer) => {
|
|
1039
|
-
stdout += data.toString()
|
|
1040
|
-
})
|
|
1041
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
1042
|
-
stderr += data.toString()
|
|
1043
|
-
})
|
|
1044
|
-
|
|
1045
|
-
// Send query and close stdin
|
|
1046
|
-
proc.stdin?.write(query + '\n')
|
|
1047
|
-
proc.stdin?.end()
|
|
1048
|
-
|
|
1049
|
-
const timeout = setTimeout(() => {
|
|
1050
|
-
proc.kill('SIGTERM')
|
|
1051
|
-
reject(new Error('Query timed out after 60 seconds'))
|
|
1052
|
-
}, 60000)
|
|
1053
|
-
|
|
1054
|
-
proc.on('error', (err) => {
|
|
1055
|
-
clearTimeout(timeout)
|
|
1056
|
-
reject(err)
|
|
1057
|
-
})
|
|
1058
|
-
|
|
1059
|
-
proc.on('close', (code) => {
|
|
1060
|
-
clearTimeout(timeout)
|
|
1061
|
-
if (code !== 0) {
|
|
1062
|
-
reject(new Error(stderr || `surreal sql exited with code ${code}`))
|
|
1063
|
-
return
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
try {
|
|
1067
|
-
// SurrealDB returns JSON array of statement results
|
|
1068
|
-
resolve(parseSurrealDBResult(stdout))
|
|
1069
|
-
} catch (error) {
|
|
1070
|
-
reject(
|
|
1071
|
-
new Error(
|
|
1072
|
-
`Failed to parse query result: ${error instanceof Error ? error.message : error}`,
|
|
1073
|
-
),
|
|
1074
|
-
)
|
|
1075
|
-
}
|
|
1076
|
-
})
|
|
1077
|
-
})
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
/**
|
|
1081
|
-
* List all databases in the container's namespace.
|
|
1082
|
-
* SurrealDB has a namespace > database hierarchy.
|
|
1083
|
-
*/
|
|
1084
|
-
async listDatabases(container: ContainerConfig): Promise<string[]> {
|
|
1085
|
-
const { port, version, name } = container
|
|
1086
|
-
const surreal = await this.getSurrealPath(version)
|
|
1087
|
-
const namespace = name.replace(/-/g, '_')
|
|
1088
|
-
|
|
1089
|
-
return new Promise((resolve, reject) => {
|
|
1090
|
-
const args = [
|
|
1091
|
-
'sql',
|
|
1092
|
-
'--endpoint',
|
|
1093
|
-
`ws://127.0.0.1:${port}`,
|
|
1094
|
-
'--user',
|
|
1095
|
-
'root',
|
|
1096
|
-
'--pass',
|
|
1097
|
-
'root',
|
|
1098
|
-
'--ns',
|
|
1099
|
-
namespace,
|
|
1100
|
-
'--db',
|
|
1101
|
-
container.database,
|
|
1102
|
-
'--hide-welcome',
|
|
1103
|
-
'--json',
|
|
1104
|
-
]
|
|
1105
|
-
|
|
1106
|
-
const proc = spawn(surreal, args, {
|
|
1107
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1108
|
-
cwd: paths.getContainerPath(name, { engine: ENGINE }),
|
|
1109
|
-
})
|
|
1110
|
-
|
|
1111
|
-
let stdout = ''
|
|
1112
|
-
let stderr = ''
|
|
1113
|
-
|
|
1114
|
-
proc.stdout?.on('data', (data: Buffer) => {
|
|
1115
|
-
stdout += data.toString()
|
|
1116
|
-
})
|
|
1117
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
1118
|
-
stderr += data.toString()
|
|
1119
|
-
})
|
|
1120
|
-
|
|
1121
|
-
proc.on('error', reject)
|
|
1122
|
-
|
|
1123
|
-
// Send the INFO FOR NS query to list databases
|
|
1124
|
-
proc.stdin?.write('INFO FOR NS;\n')
|
|
1125
|
-
proc.stdin?.end()
|
|
1126
|
-
|
|
1127
|
-
proc.on('close', (code) => {
|
|
1128
|
-
if (code !== 0) {
|
|
1129
|
-
reject(new Error(stderr || `surreal sql exited with code ${code}`))
|
|
1130
|
-
return
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
try {
|
|
1134
|
-
// Parse JSON output - INFO FOR NS returns database info
|
|
1135
|
-
const results = JSON.parse(stdout)
|
|
1136
|
-
if (Array.isArray(results) && results[0]?.result?.databases) {
|
|
1137
|
-
const databases = Object.keys(results[0].result.databases)
|
|
1138
|
-
resolve(databases)
|
|
1139
|
-
} else {
|
|
1140
|
-
// No databases found or different format
|
|
1141
|
-
resolve([container.database])
|
|
1142
|
-
}
|
|
1143
|
-
} catch {
|
|
1144
|
-
// If parsing fails, return the configured database
|
|
1145
|
-
resolve([container.database])
|
|
1146
|
-
}
|
|
1147
|
-
})
|
|
1148
|
-
})
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
async createUser(
|
|
1152
|
-
container: ContainerConfig,
|
|
1153
|
-
options: CreateUserOptions,
|
|
1154
|
-
): Promise<UserCredentials> {
|
|
1155
|
-
const { username, password, database } = options
|
|
1156
|
-
assertValidUsername(username)
|
|
1157
|
-
const { port, version, name } = container
|
|
1158
|
-
const namespace = name.replace(/-/g, '_')
|
|
1159
|
-
const db = database || container.database || 'default'
|
|
1160
|
-
|
|
1161
|
-
const surreal = await this.getSurrealPath(version)
|
|
1162
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
1163
|
-
|
|
1164
|
-
// DEFINE USER OVERWRITE with EDITOR role (idempotent)
|
|
1165
|
-
// Scope to database when options.database is provided, otherwise namespace-level
|
|
1166
|
-
// Escape backslashes first, then single quotes for SurrealQL string literals
|
|
1167
|
-
const escapedPass = password.replace(/\\/g, '\\\\').replace(/'/g, "\\'")
|
|
1168
|
-
const scopeClause = database
|
|
1169
|
-
? `ON DATABASE ${escapeSurrealIdentifier(database)}`
|
|
1170
|
-
: 'ON NAMESPACE'
|
|
1171
|
-
const sql = `DEFINE USER OVERWRITE ${escapeSurrealIdentifier(username)} ${scopeClause} PASSWORD '${escapedPass}' ROLES EDITOR;`
|
|
1172
|
-
|
|
1173
|
-
const args = [
|
|
1174
|
-
'sql',
|
|
1175
|
-
'--endpoint',
|
|
1176
|
-
`ws://127.0.0.1:${port}`,
|
|
1177
|
-
'--user',
|
|
1178
|
-
'root',
|
|
1179
|
-
'--pass',
|
|
1180
|
-
'root',
|
|
1181
|
-
'--ns',
|
|
1182
|
-
namespace,
|
|
1183
|
-
'--db',
|
|
1184
|
-
db,
|
|
1185
|
-
'--hide-welcome',
|
|
1186
|
-
]
|
|
1187
|
-
|
|
1188
|
-
const timeoutMs = 15000
|
|
1189
|
-
await new Promise<void>((resolve, reject) => {
|
|
1190
|
-
const proc = spawn(surreal, args, {
|
|
1191
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1192
|
-
cwd: containerDir,
|
|
1193
|
-
})
|
|
1194
|
-
|
|
1195
|
-
let stderr = ''
|
|
1196
|
-
let settled = false
|
|
1197
|
-
const timeoutId = setTimeout(() => {
|
|
1198
|
-
if (settled) return
|
|
1199
|
-
settled = true
|
|
1200
|
-
proc.kill()
|
|
1201
|
-
reject(
|
|
1202
|
-
new Error(
|
|
1203
|
-
`Timed out creating SurrealDB user "${username}" after ${timeoutMs}ms`,
|
|
1204
|
-
),
|
|
1205
|
-
)
|
|
1206
|
-
}, timeoutMs)
|
|
1207
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
1208
|
-
stderr += data.toString()
|
|
1209
|
-
})
|
|
1210
|
-
|
|
1211
|
-
proc.stdin?.write(sql + '\n')
|
|
1212
|
-
proc.stdin?.end()
|
|
1213
|
-
|
|
1214
|
-
proc.on('close', (code) => {
|
|
1215
|
-
if (settled) return
|
|
1216
|
-
settled = true
|
|
1217
|
-
clearTimeout(timeoutId)
|
|
1218
|
-
if (code === 0) {
|
|
1219
|
-
logDebug(`Created SurrealDB user: ${username}`)
|
|
1220
|
-
resolve()
|
|
1221
|
-
} else {
|
|
1222
|
-
reject(new Error(`Failed to create user: ${stderr}`))
|
|
1223
|
-
}
|
|
1224
|
-
})
|
|
1225
|
-
proc.on('error', (error) => {
|
|
1226
|
-
if (settled) return
|
|
1227
|
-
settled = true
|
|
1228
|
-
clearTimeout(timeoutId)
|
|
1229
|
-
reject(error)
|
|
1230
|
-
})
|
|
1231
|
-
})
|
|
1232
|
-
|
|
1233
|
-
const connectionString = `ws://127.0.0.1:${port}/rpc`
|
|
1234
|
-
|
|
1235
|
-
return {
|
|
1236
|
-
username,
|
|
1237
|
-
password,
|
|
1238
|
-
connectionString,
|
|
1239
|
-
engine: container.engine,
|
|
1240
|
-
container: container.name,
|
|
1241
|
-
database: db,
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
export const surrealdbEngine = new SurrealDBEngine()
|