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
package/engines/typedb/index.ts
DELETED
|
@@ -1,1275 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeDB Engine Implementation
|
|
3
|
-
*
|
|
4
|
-
* TypeDB is a strongly-typed database for knowledge representation and reasoning
|
|
5
|
-
* with its own query language (TypeQL).
|
|
6
|
-
*
|
|
7
|
-
* Key characteristics:
|
|
8
|
-
* - Default main port: 1729 (gRPC protocol)
|
|
9
|
-
* - HTTP port: main + 6271 (default 8000)
|
|
10
|
-
* - Rust-native binary (no JRE)
|
|
11
|
-
* - Separate console binary (typedb_console_bin) for interactive queries
|
|
12
|
-
* - Default credentials: admin/password
|
|
13
|
-
* - Config file based (config.yml per container)
|
|
14
|
-
* - Query language: TypeQL
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { spawn, type SpawnOptions } from 'child_process'
|
|
18
|
-
import { existsSync } from 'fs'
|
|
19
|
-
import { mkdir, writeFile, unlink, stat, readdir } from 'fs/promises'
|
|
20
|
-
import { join } from 'path'
|
|
21
|
-
import { tmpdir } from 'os'
|
|
22
|
-
import { BaseEngine } from '../base-engine'
|
|
23
|
-
import { paths } from '../../config/paths'
|
|
24
|
-
import { getEngineDefaults } from '../../config/defaults'
|
|
25
|
-
import { platformService } from '../../core/platform-service'
|
|
26
|
-
import { configManager } from '../../core/config-manager'
|
|
27
|
-
import {
|
|
28
|
-
logDebug,
|
|
29
|
-
logWarning,
|
|
30
|
-
assertValidUsername,
|
|
31
|
-
} from '../../core/error-handler'
|
|
32
|
-
import { processManager } from '../../core/process-manager'
|
|
33
|
-
import { typedbBinaryManager } from './binary-manager'
|
|
34
|
-
import { getBinaryUrl } from './binary-urls'
|
|
35
|
-
import {
|
|
36
|
-
normalizeVersion,
|
|
37
|
-
SUPPORTED_MAJOR_VERSIONS,
|
|
38
|
-
TYPEDB_VERSION_MAP,
|
|
39
|
-
} from './version-maps'
|
|
40
|
-
import { fetchAvailableVersions as fetchHostdbVersions } from './hostdb-releases'
|
|
41
|
-
import {
|
|
42
|
-
detectBackupFormat as detectBackupFormatImpl,
|
|
43
|
-
restoreBackup,
|
|
44
|
-
} from './restore'
|
|
45
|
-
import { createBackup } from './backup'
|
|
46
|
-
import {
|
|
47
|
-
validateTypeDBIdentifier,
|
|
48
|
-
requireTypeDBConsolePath,
|
|
49
|
-
getConsoleBaseArgs,
|
|
50
|
-
TYPEDB_DEFAULT_USERNAME,
|
|
51
|
-
TYPEDB_DEFAULT_PASSWORD,
|
|
52
|
-
} from './cli-utils'
|
|
53
|
-
import {
|
|
54
|
-
type Platform,
|
|
55
|
-
type Arch,
|
|
56
|
-
type ContainerConfig,
|
|
57
|
-
type ProgressCallback,
|
|
58
|
-
type BackupFormat,
|
|
59
|
-
type BackupOptions,
|
|
60
|
-
type BackupResult,
|
|
61
|
-
type RestoreResult,
|
|
62
|
-
type DumpResult,
|
|
63
|
-
type StatusResult,
|
|
64
|
-
type QueryResult,
|
|
65
|
-
type QueryOptions,
|
|
66
|
-
type CreateUserOptions,
|
|
67
|
-
type UserCredentials,
|
|
68
|
-
} from '../../types'
|
|
69
|
-
|
|
70
|
-
const ENGINE = 'typedb'
|
|
71
|
-
const engineDef = getEngineDefaults(ENGINE)
|
|
72
|
-
|
|
73
|
-
export class TypeDBEngine extends BaseEngine {
|
|
74
|
-
name = ENGINE
|
|
75
|
-
displayName = 'TypeDB'
|
|
76
|
-
defaultPort = engineDef.defaultPort
|
|
77
|
-
supportedVersions = SUPPORTED_MAJOR_VERSIONS
|
|
78
|
-
|
|
79
|
-
// Get platform info for binary operations
|
|
80
|
-
getPlatformInfo(): { platform: Platform; arch: Arch } {
|
|
81
|
-
return platformService.getPlatformInfo()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Fetch available versions from hostdb (dynamically or from cache/fallback)
|
|
85
|
-
async fetchAvailableVersions(): Promise<Record<string, string[]>> {
|
|
86
|
-
return fetchHostdbVersions()
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Get binary download URL from hostdb
|
|
90
|
-
getBinaryUrl(version: string, platform: Platform, arch: Arch): string {
|
|
91
|
-
return getBinaryUrl(version, platform, arch)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Resolves version string to full version (e.g., '3' -> '3.8.0')
|
|
95
|
-
resolveFullVersion(version: string): string {
|
|
96
|
-
if (/^\d+\.\d+\.\d+$/.test(version)) {
|
|
97
|
-
return version
|
|
98
|
-
}
|
|
99
|
-
return TYPEDB_VERSION_MAP[version] || version
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Get the path where binaries for a version would be installed
|
|
103
|
-
getBinaryPath(version: string): string {
|
|
104
|
-
const fullVersion = this.resolveFullVersion(version)
|
|
105
|
-
const { platform: p, arch: a } = this.getPlatformInfo()
|
|
106
|
-
return paths.getBinaryPath({
|
|
107
|
-
engine: 'typedb',
|
|
108
|
-
version: fullVersion,
|
|
109
|
-
platform: p,
|
|
110
|
-
arch: a,
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Verify that TypeDB binaries are available
|
|
115
|
-
async verifyBinary(binPath: string): Promise<boolean> {
|
|
116
|
-
const ext = platformService.getExecutableExtension()
|
|
117
|
-
const serverPath = join(binPath, 'bin', 'server', `typedb_server_bin${ext}`)
|
|
118
|
-
return existsSync(serverPath)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Check if a specific TypeDB version is installed (downloaded)
|
|
122
|
-
async isBinaryInstalled(version: string): Promise<boolean> {
|
|
123
|
-
const { platform, arch } = this.getPlatformInfo()
|
|
124
|
-
return typedbBinaryManager.isInstalled(version, platform, arch)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Ensure TypeDB binaries are available for a specific version
|
|
129
|
-
* Downloads from hostdb if not already installed
|
|
130
|
-
* Returns the path to the bin directory
|
|
131
|
-
*/
|
|
132
|
-
async ensureBinaries(
|
|
133
|
-
version: string,
|
|
134
|
-
onProgress?: ProgressCallback,
|
|
135
|
-
): Promise<string> {
|
|
136
|
-
const { platform, arch } = this.getPlatformInfo()
|
|
137
|
-
|
|
138
|
-
const binPath = await typedbBinaryManager.ensureInstalled(
|
|
139
|
-
version,
|
|
140
|
-
platform,
|
|
141
|
-
arch,
|
|
142
|
-
onProgress,
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
// Register binaries in config
|
|
146
|
-
const ext = platformService.getExecutableExtension()
|
|
147
|
-
const batExt = process.platform === 'win32' ? '.bat' : ''
|
|
148
|
-
|
|
149
|
-
const typedbPath = join(binPath, 'bin', `typedb${batExt}`)
|
|
150
|
-
if (existsSync(typedbPath)) {
|
|
151
|
-
await configManager.setBinaryPath('typedb', typedbPath, 'bundled')
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const consolePath = join(
|
|
155
|
-
binPath,
|
|
156
|
-
'bin',
|
|
157
|
-
'console',
|
|
158
|
-
`typedb_console_bin${ext}`,
|
|
159
|
-
)
|
|
160
|
-
if (existsSync(consolePath)) {
|
|
161
|
-
await configManager.setBinaryPath(
|
|
162
|
-
'typedb_console_bin',
|
|
163
|
-
consolePath,
|
|
164
|
-
'bundled',
|
|
165
|
-
)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return binPath
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Initialize a new TypeDB data directory
|
|
173
|
-
* Creates the directory structure and config.yml for TypeDB
|
|
174
|
-
*/
|
|
175
|
-
async initDataDir(
|
|
176
|
-
containerName: string,
|
|
177
|
-
_version: string,
|
|
178
|
-
options: Record<string, unknown> = {},
|
|
179
|
-
): Promise<string> {
|
|
180
|
-
const containerDir = paths.getContainerPath(containerName, {
|
|
181
|
-
engine: ENGINE,
|
|
182
|
-
})
|
|
183
|
-
const dataDir = paths.getContainerDataPath(containerName, {
|
|
184
|
-
engine: ENGINE,
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
// Create data directory
|
|
188
|
-
await mkdir(dataDir, { recursive: true })
|
|
189
|
-
|
|
190
|
-
// Get port from options or use default
|
|
191
|
-
const port = (options.port as number) || engineDef.defaultPort
|
|
192
|
-
const httpPort = port + 6271 // Default: 1729 + 6271 = 8000
|
|
193
|
-
|
|
194
|
-
// Generate config.yml for this container
|
|
195
|
-
// Must include all required sections: server (with authentication, encryption), storage, logging, diagnostics
|
|
196
|
-
// Use forward slashes in YAML paths - backslashes in double-quoted YAML strings are
|
|
197
|
-
// interpreted as escape sequences (\t → tab, \n → newline, etc.) which corrupts Windows paths
|
|
198
|
-
const yamlDataDir = dataDir.replace(/\\/g, '/')
|
|
199
|
-
const yamlContainerDir = containerDir.replace(/\\/g, '/')
|
|
200
|
-
const configContent = [
|
|
201
|
-
'server:',
|
|
202
|
-
` address: 127.0.0.1:${port}`,
|
|
203
|
-
' http:',
|
|
204
|
-
' enabled: true',
|
|
205
|
-
` address: 127.0.0.1:${httpPort}`,
|
|
206
|
-
' authentication:',
|
|
207
|
-
' token-expiration-seconds: 5000',
|
|
208
|
-
' encryption:',
|
|
209
|
-
' enabled: false',
|
|
210
|
-
' certificate:',
|
|
211
|
-
' certificate-key:',
|
|
212
|
-
' ca-certificate:',
|
|
213
|
-
'storage:',
|
|
214
|
-
` data-directory: "${yamlDataDir}"`,
|
|
215
|
-
'logging:',
|
|
216
|
-
` directory: "${yamlContainerDir}"`,
|
|
217
|
-
'diagnostics:',
|
|
218
|
-
' reporting:',
|
|
219
|
-
' metrics: false',
|
|
220
|
-
' errors: false',
|
|
221
|
-
' monitoring:',
|
|
222
|
-
' enabled: false',
|
|
223
|
-
' port: 4104',
|
|
224
|
-
].join('\n')
|
|
225
|
-
|
|
226
|
-
await writeFile(join(containerDir, 'config.yml'), configContent, 'utf-8')
|
|
227
|
-
|
|
228
|
-
logDebug(`Created TypeDB data directory: ${dataDir}`)
|
|
229
|
-
|
|
230
|
-
return dataDir
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Get the path to typedb_server_bin for a version
|
|
234
|
-
private async getServerBinPath(version: string): Promise<string> {
|
|
235
|
-
const { platform, arch } = this.getPlatformInfo()
|
|
236
|
-
const fullVersion = normalizeVersion(version)
|
|
237
|
-
const ext = platformService.getExecutableExtension()
|
|
238
|
-
|
|
239
|
-
const binPath = paths.getBinaryPath({
|
|
240
|
-
engine: 'typedb',
|
|
241
|
-
version: fullVersion,
|
|
242
|
-
platform,
|
|
243
|
-
arch,
|
|
244
|
-
})
|
|
245
|
-
const serverPath = join(binPath, 'bin', 'server', `typedb_server_bin${ext}`)
|
|
246
|
-
|
|
247
|
-
if (existsSync(serverPath)) {
|
|
248
|
-
return serverPath
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
throw new Error(
|
|
252
|
-
`TypeDB ${version} is not installed. Run: spindb engines download typedb ${version}`,
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Get the path to typedb_console_bin for a version
|
|
257
|
-
private async getConsolePath(version: string): Promise<string> {
|
|
258
|
-
const { platform, arch } = this.getPlatformInfo()
|
|
259
|
-
const fullVersion = normalizeVersion(version)
|
|
260
|
-
const ext = platformService.getExecutableExtension()
|
|
261
|
-
|
|
262
|
-
const binPath = paths.getBinaryPath({
|
|
263
|
-
engine: 'typedb',
|
|
264
|
-
version: fullVersion,
|
|
265
|
-
platform,
|
|
266
|
-
arch,
|
|
267
|
-
})
|
|
268
|
-
const consolePath = join(
|
|
269
|
-
binPath,
|
|
270
|
-
'bin',
|
|
271
|
-
'console',
|
|
272
|
-
`typedb_console_bin${ext}`,
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
if (existsSync(consolePath)) {
|
|
276
|
-
return consolePath
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
throw new Error(
|
|
280
|
-
`TypeDB console ${version} is not installed. Run: spindb engines download typedb ${version}`,
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Get the typedb launcher path for a version
|
|
285
|
-
private async getTypeDBLauncherPath(version: string): Promise<string> {
|
|
286
|
-
const { platform, arch } = this.getPlatformInfo()
|
|
287
|
-
const fullVersion = normalizeVersion(version)
|
|
288
|
-
const batExt = process.platform === 'win32' ? '.bat' : ''
|
|
289
|
-
|
|
290
|
-
const binPath = paths.getBinaryPath({
|
|
291
|
-
engine: 'typedb',
|
|
292
|
-
version: fullVersion,
|
|
293
|
-
platform,
|
|
294
|
-
arch,
|
|
295
|
-
})
|
|
296
|
-
const launcherPath = join(binPath, 'bin', `typedb${batExt}`)
|
|
297
|
-
|
|
298
|
-
if (existsSync(launcherPath)) {
|
|
299
|
-
return launcherPath
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Fall back to direct server binary
|
|
303
|
-
return this.getServerBinPath(version)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Start TypeDB server
|
|
308
|
-
*/
|
|
309
|
-
async start(
|
|
310
|
-
container: ContainerConfig,
|
|
311
|
-
onProgress?: ProgressCallback,
|
|
312
|
-
): Promise<{ port: number; connectionString: string }> {
|
|
313
|
-
const { name, port, version, binaryPath } = container
|
|
314
|
-
|
|
315
|
-
// Check if already running
|
|
316
|
-
const alreadyRunning = await processManager.isRunning(name, {
|
|
317
|
-
engine: ENGINE,
|
|
318
|
-
})
|
|
319
|
-
if (alreadyRunning) {
|
|
320
|
-
return {
|
|
321
|
-
port,
|
|
322
|
-
connectionString: this.getConnectionString(container),
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// Get TypeDB binary path
|
|
327
|
-
let serverBinary: string | null = null
|
|
328
|
-
const ext = platformService.getExecutableExtension()
|
|
329
|
-
|
|
330
|
-
if (binaryPath && existsSync(binaryPath)) {
|
|
331
|
-
const serverPath = join(
|
|
332
|
-
binaryPath,
|
|
333
|
-
'bin',
|
|
334
|
-
'server',
|
|
335
|
-
`typedb_server_bin${ext}`,
|
|
336
|
-
)
|
|
337
|
-
if (existsSync(serverPath)) {
|
|
338
|
-
serverBinary = serverPath
|
|
339
|
-
logDebug(`Using stored binary path: ${serverBinary}`)
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (!serverBinary) {
|
|
344
|
-
try {
|
|
345
|
-
serverBinary = await this.getServerBinPath(version)
|
|
346
|
-
} catch (error) {
|
|
347
|
-
const originalMessage =
|
|
348
|
-
error instanceof Error ? error.message : String(error)
|
|
349
|
-
throw new Error(
|
|
350
|
-
`TypeDB ${version} is not installed. Run: spindb engines download typedb ${version}\n` +
|
|
351
|
-
` Original error: ${originalMessage}`,
|
|
352
|
-
)
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
357
|
-
const pidFile = join(containerDir, 'typedb.pid')
|
|
358
|
-
const configFile = join(containerDir, 'config.yml')
|
|
359
|
-
|
|
360
|
-
// Always regenerate config.yml to ensure paths and port are correct
|
|
361
|
-
// (paths change after rename, port changes after port reassignment)
|
|
362
|
-
await this.initDataDir(name, version, { port })
|
|
363
|
-
|
|
364
|
-
onProgress?.({ stage: 'starting', message: 'Starting TypeDB...' })
|
|
365
|
-
|
|
366
|
-
logDebug(`Starting TypeDB with config: ${configFile}`)
|
|
367
|
-
|
|
368
|
-
// TypeDB server start using direct server binary with config
|
|
369
|
-
const args = ['server', '--config', configFile]
|
|
370
|
-
|
|
371
|
-
// On Windows, use server binary directly to avoid .bat launcher's cmd.exe wrapper
|
|
372
|
-
// which creates orphaned processes that prevent clean test/CLI exit.
|
|
373
|
-
// On other platforms, try launcher first, fall back to direct server binary.
|
|
374
|
-
const isWindows = process.platform === 'win32'
|
|
375
|
-
let launcherPath: string
|
|
376
|
-
if (isWindows && serverBinary) {
|
|
377
|
-
launcherPath = serverBinary
|
|
378
|
-
// When using server binary directly, don't pass 'server' subcommand
|
|
379
|
-
args.splice(0, 1)
|
|
380
|
-
} else {
|
|
381
|
-
try {
|
|
382
|
-
launcherPath = await this.getTypeDBLauncherPath(version)
|
|
383
|
-
} catch {
|
|
384
|
-
launcherPath = serverBinary!
|
|
385
|
-
// When using server binary directly, don't pass 'server' subcommand
|
|
386
|
-
args.splice(0, 1)
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// Spawn the server process
|
|
391
|
-
// Use 'ignore' for all stdio to prevent pipes from keeping the event loop alive
|
|
392
|
-
// On Windows, .bat/.cmd files would require shell: true, but we use the .exe directly
|
|
393
|
-
const needsShell =
|
|
394
|
-
isWindows &&
|
|
395
|
-
(launcherPath.endsWith('.bat') || launcherPath.endsWith('.cmd'))
|
|
396
|
-
|
|
397
|
-
const proc = spawn(launcherPath, args, {
|
|
398
|
-
stdio: ['ignore', 'ignore', 'ignore'],
|
|
399
|
-
detached: true,
|
|
400
|
-
cwd: containerDir,
|
|
401
|
-
windowsHide: true,
|
|
402
|
-
...(needsShell ? { shell: true } : {}),
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
// Wait for the process to spawn
|
|
406
|
-
if (isWindows) {
|
|
407
|
-
await new Promise<void>((resolve, reject) => {
|
|
408
|
-
let settled = false
|
|
409
|
-
|
|
410
|
-
proc.on('error', (err) => {
|
|
411
|
-
if (settled) return
|
|
412
|
-
settled = true
|
|
413
|
-
logDebug(`TypeDB spawn error on Windows: ${err.message}`)
|
|
414
|
-
reject(new Error(`Failed to spawn TypeDB: ${err.message}`))
|
|
415
|
-
})
|
|
416
|
-
|
|
417
|
-
// Detect early exit (e.g., bad config, missing deps)
|
|
418
|
-
proc.on('close', (code, signal) => {
|
|
419
|
-
if (settled) return
|
|
420
|
-
settled = true
|
|
421
|
-
const errMsg = `TypeDB process exited early on Windows (code: ${code}, signal: ${signal})`
|
|
422
|
-
logDebug(errMsg)
|
|
423
|
-
reject(new Error(errMsg))
|
|
424
|
-
})
|
|
425
|
-
|
|
426
|
-
if (proc.pid) {
|
|
427
|
-
writeFile(pidFile, proc.pid.toString(), 'utf-8')
|
|
428
|
-
.then(() => {
|
|
429
|
-
logDebug(`Windows: wrote PID file ${pidFile} (pid: ${proc.pid})`)
|
|
430
|
-
proc.unref()
|
|
431
|
-
setTimeout(() => {
|
|
432
|
-
if (settled) return
|
|
433
|
-
settled = true
|
|
434
|
-
proc.removeAllListeners('close')
|
|
435
|
-
resolve()
|
|
436
|
-
}, 3000)
|
|
437
|
-
})
|
|
438
|
-
.catch((err) => {
|
|
439
|
-
if (settled) return
|
|
440
|
-
settled = true
|
|
441
|
-
const errMsg = `Failed to write PID file: ${err instanceof Error ? err.message : String(err)}`
|
|
442
|
-
logDebug(errMsg)
|
|
443
|
-
try {
|
|
444
|
-
if (proc.pid) process.kill(proc.pid, 'SIGTERM')
|
|
445
|
-
} catch {
|
|
446
|
-
// Process may have already exited
|
|
447
|
-
}
|
|
448
|
-
reject(new Error(errMsg))
|
|
449
|
-
})
|
|
450
|
-
} else {
|
|
451
|
-
settled = true
|
|
452
|
-
reject(new Error('Failed to spawn TypeDB: no PID available'))
|
|
453
|
-
}
|
|
454
|
-
})
|
|
455
|
-
} else {
|
|
456
|
-
const spawnTimeout = 30000
|
|
457
|
-
await new Promise<void>((resolve, reject) => {
|
|
458
|
-
const timeoutId = setTimeout(() => {
|
|
459
|
-
reject(
|
|
460
|
-
new Error(
|
|
461
|
-
`TypeDB process failed to spawn within ${spawnTimeout}ms`,
|
|
462
|
-
),
|
|
463
|
-
)
|
|
464
|
-
}, spawnTimeout)
|
|
465
|
-
|
|
466
|
-
proc.on('error', (err) => {
|
|
467
|
-
clearTimeout(timeoutId)
|
|
468
|
-
logDebug(`TypeDB spawn error: ${err.message}`)
|
|
469
|
-
reject(new Error(`Failed to spawn TypeDB: ${err.message}`))
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
proc.on('close', (code, signal) => {
|
|
473
|
-
clearTimeout(timeoutId)
|
|
474
|
-
const errMsg = `TypeDB process exited early (code: ${code}, signal: ${signal})`
|
|
475
|
-
logDebug(errMsg)
|
|
476
|
-
reject(new Error(errMsg))
|
|
477
|
-
})
|
|
478
|
-
|
|
479
|
-
proc.on('spawn', async () => {
|
|
480
|
-
clearTimeout(timeoutId)
|
|
481
|
-
logDebug(`TypeDB process spawned (pid: ${proc.pid})`)
|
|
482
|
-
|
|
483
|
-
proc.removeAllListeners('close')
|
|
484
|
-
|
|
485
|
-
if (proc.pid) {
|
|
486
|
-
try {
|
|
487
|
-
await writeFile(pidFile, proc.pid.toString(), 'utf-8')
|
|
488
|
-
} catch (err) {
|
|
489
|
-
const errMsg = `Failed to write PID file: ${err instanceof Error ? err.message : String(err)}`
|
|
490
|
-
logDebug(errMsg)
|
|
491
|
-
|
|
492
|
-
try {
|
|
493
|
-
process.kill(proc.pid, 'SIGTERM')
|
|
494
|
-
} catch {
|
|
495
|
-
// Process may have already exited
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
try {
|
|
499
|
-
await unlink(pidFile)
|
|
500
|
-
} catch {
|
|
501
|
-
// Ignore
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
reject(new Error(errMsg))
|
|
505
|
-
return
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
proc.unref()
|
|
510
|
-
setTimeout(resolve, 500)
|
|
511
|
-
})
|
|
512
|
-
})
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// Wait for server to be ready
|
|
516
|
-
const httpPort = port + 6271
|
|
517
|
-
logDebug(
|
|
518
|
-
`Waiting for TypeDB server to be ready on port ${port} (HTTP: ${httpPort})...`,
|
|
519
|
-
)
|
|
520
|
-
const ready = await this.waitForReady(httpPort, port)
|
|
521
|
-
logDebug(`waitForReady returned: ${ready}`)
|
|
522
|
-
|
|
523
|
-
if (!ready) {
|
|
524
|
-
throw new Error(
|
|
525
|
-
`TypeDB failed to start within timeout. Container: ${name}`,
|
|
526
|
-
)
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
// On Windows with .bat launcher, the recorded PID is cmd.exe (not the actual server).
|
|
530
|
-
// Find the real server PID by port and update the PID file (same pattern as QuestDB).
|
|
531
|
-
if (isWindows) {
|
|
532
|
-
try {
|
|
533
|
-
const pids = await platformService.findProcessByPort(port)
|
|
534
|
-
if (pids.length > 0) {
|
|
535
|
-
await writeFile(pidFile, pids[0].toString(), 'utf-8')
|
|
536
|
-
logDebug(
|
|
537
|
-
`Windows: updated PID file with actual server PID: ${pids[0]}`,
|
|
538
|
-
)
|
|
539
|
-
}
|
|
540
|
-
} catch {
|
|
541
|
-
// Non-fatal: stop() also looks up by port
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
return {
|
|
546
|
-
port,
|
|
547
|
-
connectionString: this.getConnectionString(container),
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// Wait for TypeDB to be ready via HTTP health check
|
|
552
|
-
private async waitForReady(
|
|
553
|
-
httpPort: number,
|
|
554
|
-
_mainPort: number,
|
|
555
|
-
timeoutMs = 60000,
|
|
556
|
-
): Promise<boolean> {
|
|
557
|
-
logDebug(`waitForReady called for HTTP port ${httpPort}`)
|
|
558
|
-
const startTime = Date.now()
|
|
559
|
-
const checkInterval = 500
|
|
560
|
-
|
|
561
|
-
let attempt = 0
|
|
562
|
-
while (Date.now() - startTime < timeoutMs) {
|
|
563
|
-
attempt++
|
|
564
|
-
const controller = new AbortController()
|
|
565
|
-
const timer = setTimeout(() => controller.abort(), 5000)
|
|
566
|
-
try {
|
|
567
|
-
const response = await fetch(`http://127.0.0.1:${httpPort}/health`, {
|
|
568
|
-
signal: controller.signal,
|
|
569
|
-
})
|
|
570
|
-
clearTimeout(timer)
|
|
571
|
-
|
|
572
|
-
if (response.ok) {
|
|
573
|
-
logDebug(`TypeDB ready on HTTP port ${httpPort}`)
|
|
574
|
-
return true
|
|
575
|
-
}
|
|
576
|
-
} catch {
|
|
577
|
-
clearTimeout(timer)
|
|
578
|
-
if (attempt <= 3 || attempt % 10 === 0) {
|
|
579
|
-
logDebug(`Health check attempt ${attempt} failed`)
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
await new Promise((resolve) => setTimeout(resolve, checkInterval))
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
logWarning(`TypeDB did not become ready within ${timeoutMs}ms`)
|
|
586
|
-
return false
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* Stop TypeDB server
|
|
591
|
-
*/
|
|
592
|
-
async stop(container: ContainerConfig): Promise<void> {
|
|
593
|
-
const { name, port } = container
|
|
594
|
-
const containerDir = paths.getContainerPath(name, { engine: ENGINE })
|
|
595
|
-
const pidFile = join(containerDir, 'typedb.pid')
|
|
596
|
-
|
|
597
|
-
logDebug(`Stopping TypeDB container "${name}" on port ${port}`)
|
|
598
|
-
|
|
599
|
-
// Find PID by port
|
|
600
|
-
let pid: number | null = null
|
|
601
|
-
|
|
602
|
-
try {
|
|
603
|
-
const pids = await platformService.findProcessByPort(port)
|
|
604
|
-
if (pids.length > 0) {
|
|
605
|
-
pid = pids[0]
|
|
606
|
-
}
|
|
607
|
-
} catch {
|
|
608
|
-
// Ignore
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// Kill process if found
|
|
612
|
-
if (pid && platformService.isProcessRunning(pid)) {
|
|
613
|
-
logDebug(`Killing TypeDB process ${pid}`)
|
|
614
|
-
try {
|
|
615
|
-
await platformService.terminateProcess(pid, false)
|
|
616
|
-
const gracefulWait = process.platform === 'win32' ? 5000 : 2000
|
|
617
|
-
await new Promise((resolve) => setTimeout(resolve, gracefulWait))
|
|
618
|
-
|
|
619
|
-
if (platformService.isProcessRunning(pid)) {
|
|
620
|
-
logWarning(`Graceful termination failed, force killing ${pid}`)
|
|
621
|
-
await platformService.terminateProcess(pid, true)
|
|
622
|
-
if (process.platform === 'win32') {
|
|
623
|
-
await new Promise((resolve) => setTimeout(resolve, 3000))
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
} catch (error) {
|
|
627
|
-
logDebug(`Process termination error: ${error}`)
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// Cleanup PID file
|
|
632
|
-
if (existsSync(pidFile)) {
|
|
633
|
-
try {
|
|
634
|
-
await unlink(pidFile)
|
|
635
|
-
} catch {
|
|
636
|
-
// Ignore
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
logDebug('TypeDB stopped')
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// Get TypeDB server status
|
|
644
|
-
async status(container: ContainerConfig): Promise<StatusResult> {
|
|
645
|
-
const { port } = container
|
|
646
|
-
const httpPort = port + 6271
|
|
647
|
-
|
|
648
|
-
try {
|
|
649
|
-
const controller = new AbortController()
|
|
650
|
-
const timer = setTimeout(() => controller.abort(), 5000)
|
|
651
|
-
|
|
652
|
-
const response = await fetch(`http://127.0.0.1:${httpPort}/health`, {
|
|
653
|
-
signal: controller.signal,
|
|
654
|
-
})
|
|
655
|
-
clearTimeout(timer)
|
|
656
|
-
|
|
657
|
-
if (response.ok) {
|
|
658
|
-
return { running: true, message: 'TypeDB is running' }
|
|
659
|
-
}
|
|
660
|
-
return { running: false, message: 'TypeDB is not running' }
|
|
661
|
-
} catch {
|
|
662
|
-
return { running: false, message: 'TypeDB is not running' }
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
// Detect backup format
|
|
667
|
-
async detectBackupFormat(filePath: string): Promise<BackupFormat> {
|
|
668
|
-
return detectBackupFormatImpl(filePath)
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Restore a backup
|
|
673
|
-
*/
|
|
674
|
-
async restore(
|
|
675
|
-
container: ContainerConfig,
|
|
676
|
-
backupPath: string,
|
|
677
|
-
options: { database?: string } = {},
|
|
678
|
-
): Promise<RestoreResult> {
|
|
679
|
-
const { name, port, version } = container
|
|
680
|
-
|
|
681
|
-
return restoreBackup(backupPath, {
|
|
682
|
-
containerName: name,
|
|
683
|
-
port,
|
|
684
|
-
database: options.database || container.database,
|
|
685
|
-
version,
|
|
686
|
-
})
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Get connection string
|
|
691
|
-
* TypeDB uses its own protocol on the main port
|
|
692
|
-
*/
|
|
693
|
-
getConnectionString(container: ContainerConfig, _database?: string): string {
|
|
694
|
-
const { port } = container
|
|
695
|
-
return `typedb://${TYPEDB_DEFAULT_USERNAME}:${TYPEDB_DEFAULT_PASSWORD}@127.0.0.1:${port}`
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
// Open TypeDB console interactive shell
|
|
699
|
-
async connect(container: ContainerConfig, _database?: string): Promise<void> {
|
|
700
|
-
const { port, version } = container
|
|
701
|
-
|
|
702
|
-
const consolePath = await this.getConsolePath(version)
|
|
703
|
-
|
|
704
|
-
const spawnOptions: SpawnOptions = {
|
|
705
|
-
stdio: 'inherit',
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
return new Promise((resolve, reject) => {
|
|
709
|
-
const proc = spawn(consolePath, getConsoleBaseArgs(port), spawnOptions)
|
|
710
|
-
|
|
711
|
-
proc.on('error', reject)
|
|
712
|
-
proc.on('close', () => resolve())
|
|
713
|
-
})
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* Create a new database
|
|
718
|
-
* TypeDB requires explicit database creation via console
|
|
719
|
-
*/
|
|
720
|
-
async createDatabase(
|
|
721
|
-
container: ContainerConfig,
|
|
722
|
-
database: string,
|
|
723
|
-
): Promise<void> {
|
|
724
|
-
const { port, version } = container
|
|
725
|
-
|
|
726
|
-
validateTypeDBIdentifier(database)
|
|
727
|
-
|
|
728
|
-
const consolePath = await this.getConsolePath(version)
|
|
729
|
-
|
|
730
|
-
const args = [
|
|
731
|
-
...getConsoleBaseArgs(port),
|
|
732
|
-
'--command',
|
|
733
|
-
`database create ${database}`,
|
|
734
|
-
]
|
|
735
|
-
|
|
736
|
-
await new Promise<void>((resolve, reject) => {
|
|
737
|
-
const proc = spawn(consolePath, args, {
|
|
738
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
739
|
-
})
|
|
740
|
-
|
|
741
|
-
let stderr = ''
|
|
742
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
743
|
-
stderr += data.toString()
|
|
744
|
-
})
|
|
745
|
-
|
|
746
|
-
proc.on('close', (code) => {
|
|
747
|
-
if (code === 0) {
|
|
748
|
-
logDebug(`Created TypeDB database: ${database}`)
|
|
749
|
-
resolve()
|
|
750
|
-
} else {
|
|
751
|
-
reject(new Error(`Failed to create database: ${stderr}`))
|
|
752
|
-
}
|
|
753
|
-
})
|
|
754
|
-
proc.on('error', reject)
|
|
755
|
-
})
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
/**
|
|
759
|
-
* Drop a database
|
|
760
|
-
*/
|
|
761
|
-
async dropDatabase(
|
|
762
|
-
container: ContainerConfig,
|
|
763
|
-
database: string,
|
|
764
|
-
): Promise<void> {
|
|
765
|
-
const { port, version } = container
|
|
766
|
-
|
|
767
|
-
validateTypeDBIdentifier(database)
|
|
768
|
-
|
|
769
|
-
const consolePath = await this.getConsolePath(version)
|
|
770
|
-
|
|
771
|
-
const args = [
|
|
772
|
-
...getConsoleBaseArgs(port),
|
|
773
|
-
'--command',
|
|
774
|
-
`database delete ${database}`,
|
|
775
|
-
]
|
|
776
|
-
|
|
777
|
-
await new Promise<void>((resolve, reject) => {
|
|
778
|
-
const proc = spawn(consolePath, args, {
|
|
779
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
780
|
-
})
|
|
781
|
-
|
|
782
|
-
let stderr = ''
|
|
783
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
784
|
-
stderr += data.toString()
|
|
785
|
-
})
|
|
786
|
-
|
|
787
|
-
proc.on('close', (code) => {
|
|
788
|
-
if (code === 0) {
|
|
789
|
-
logDebug(`Dropped TypeDB database: ${database}`)
|
|
790
|
-
resolve()
|
|
791
|
-
} else {
|
|
792
|
-
reject(new Error(`Failed to drop database: ${stderr}`))
|
|
793
|
-
}
|
|
794
|
-
})
|
|
795
|
-
proc.on('error', reject)
|
|
796
|
-
})
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* Get the database size in bytes
|
|
801
|
-
* Estimate from data directory
|
|
802
|
-
*/
|
|
803
|
-
async getDatabaseSize(container: ContainerConfig): Promise<number | null> {
|
|
804
|
-
const dataDir = paths.getContainerDataPath(container.name, {
|
|
805
|
-
engine: ENGINE,
|
|
806
|
-
})
|
|
807
|
-
|
|
808
|
-
try {
|
|
809
|
-
const stats = await stat(dataDir)
|
|
810
|
-
|
|
811
|
-
if (!stats.isDirectory()) {
|
|
812
|
-
return null
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
let totalSize = 0
|
|
816
|
-
const calculateSize = async (dir: string): Promise<void> => {
|
|
817
|
-
const entries = await readdir(dir, { withFileTypes: true })
|
|
818
|
-
for (const entry of entries) {
|
|
819
|
-
const fullPath = join(dir, entry.name)
|
|
820
|
-
if (entry.isDirectory()) {
|
|
821
|
-
await calculateSize(fullPath)
|
|
822
|
-
} else {
|
|
823
|
-
const fileStat = await stat(fullPath)
|
|
824
|
-
totalSize += fileStat.size
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
await calculateSize(dataDir)
|
|
830
|
-
return totalSize
|
|
831
|
-
} catch {
|
|
832
|
-
return null
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
/**
|
|
837
|
-
* Dump from a remote TypeDB connection
|
|
838
|
-
* Uses TypeDB console export
|
|
839
|
-
*/
|
|
840
|
-
async dumpFromConnectionString(
|
|
841
|
-
connectionString: string,
|
|
842
|
-
outputPath: string,
|
|
843
|
-
): Promise<DumpResult> {
|
|
844
|
-
// Parse connection string
|
|
845
|
-
let url: URL
|
|
846
|
-
try {
|
|
847
|
-
url = new URL(connectionString)
|
|
848
|
-
} catch {
|
|
849
|
-
const sanitized = connectionString.replace(
|
|
850
|
-
/\/\/([^:]+):([^@]+)@/,
|
|
851
|
-
'//***:***@',
|
|
852
|
-
)
|
|
853
|
-
throw new Error(
|
|
854
|
-
`Invalid connection string: ${sanitized}\n` +
|
|
855
|
-
'Expected format: typedb://host[:port][/database]',
|
|
856
|
-
)
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
const host = url.hostname || '127.0.0.1'
|
|
860
|
-
const port = parseInt(url.port, 10) || 1729
|
|
861
|
-
const database = url.pathname.replace(/^\//, '') || 'default'
|
|
862
|
-
const username = url.username
|
|
863
|
-
? decodeURIComponent(url.username)
|
|
864
|
-
: TYPEDB_DEFAULT_USERNAME
|
|
865
|
-
const password = url.password
|
|
866
|
-
? decodeURIComponent(url.password)
|
|
867
|
-
: TYPEDB_DEFAULT_PASSWORD
|
|
868
|
-
|
|
869
|
-
logDebug(`Connecting to remote TypeDB at ${host}:${port} (db: ${database})`)
|
|
870
|
-
|
|
871
|
-
// For remote dump, we need a local TypeDB console binary
|
|
872
|
-
let consolePath: string | null = null
|
|
873
|
-
const cached = await configManager.getBinaryPath('typedb_console_bin')
|
|
874
|
-
if (cached && existsSync(cached)) {
|
|
875
|
-
consolePath = cached
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
if (!consolePath) {
|
|
879
|
-
throw new Error(
|
|
880
|
-
'TypeDB console binary not found. Run: spindb engines download typedb 3\n' +
|
|
881
|
-
'A local TypeDB console binary is needed to dump from remote connections.',
|
|
882
|
-
)
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
// TypeDB exports schema and data as separate files
|
|
886
|
-
let schemaPath: string
|
|
887
|
-
let dataPath: string
|
|
888
|
-
if (outputPath.endsWith('.typeql')) {
|
|
889
|
-
const basePath = outputPath.slice(0, -'.typeql'.length)
|
|
890
|
-
schemaPath = `${basePath}-schema.typeql`
|
|
891
|
-
dataPath = `${basePath}-data.typeql`
|
|
892
|
-
} else {
|
|
893
|
-
schemaPath = outputPath + '-schema.typeql'
|
|
894
|
-
dataPath = outputPath + '-data.typeql'
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
// Build console args with URL credentials (may differ from local defaults)
|
|
898
|
-
const tlsDisabled = url.protocol !== 'https:'
|
|
899
|
-
return new Promise<DumpResult>((resolve, reject) => {
|
|
900
|
-
const args = [
|
|
901
|
-
'--address',
|
|
902
|
-
`${host}:${port}`,
|
|
903
|
-
...(tlsDisabled ? ['--tls-disabled'] : []),
|
|
904
|
-
'--username',
|
|
905
|
-
username,
|
|
906
|
-
'--password',
|
|
907
|
-
password,
|
|
908
|
-
'--command',
|
|
909
|
-
`database export ${database} ${schemaPath} ${dataPath}`,
|
|
910
|
-
]
|
|
911
|
-
|
|
912
|
-
const proc = spawn(consolePath!, args, {
|
|
913
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
914
|
-
})
|
|
915
|
-
|
|
916
|
-
let stdout = ''
|
|
917
|
-
let stderr = ''
|
|
918
|
-
|
|
919
|
-
proc.stdout.on('data', (data: Buffer) => {
|
|
920
|
-
stdout += data.toString()
|
|
921
|
-
})
|
|
922
|
-
proc.stderr.on('data', (data: Buffer) => {
|
|
923
|
-
stderr += data.toString()
|
|
924
|
-
})
|
|
925
|
-
|
|
926
|
-
proc.on('close', (code) => {
|
|
927
|
-
if (code === 0) {
|
|
928
|
-
resolve({
|
|
929
|
-
filePath: outputPath,
|
|
930
|
-
stdout,
|
|
931
|
-
stderr,
|
|
932
|
-
code: 0,
|
|
933
|
-
})
|
|
934
|
-
} else {
|
|
935
|
-
reject(new Error(stderr || `Exit code ${code}`))
|
|
936
|
-
}
|
|
937
|
-
})
|
|
938
|
-
proc.on('error', reject)
|
|
939
|
-
})
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
// Create a backup
|
|
943
|
-
async backup(
|
|
944
|
-
container: ContainerConfig,
|
|
945
|
-
outputPath: string,
|
|
946
|
-
options: BackupOptions,
|
|
947
|
-
): Promise<BackupResult> {
|
|
948
|
-
return createBackup(container, outputPath, options)
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
// Run a TypeQL file or inline statement
|
|
952
|
-
async runScript(
|
|
953
|
-
container: ContainerConfig,
|
|
954
|
-
options: {
|
|
955
|
-
file?: string
|
|
956
|
-
sql?: string
|
|
957
|
-
database?: string
|
|
958
|
-
transactionType?: 'read' | 'write' | 'schema'
|
|
959
|
-
},
|
|
960
|
-
): Promise<void> {
|
|
961
|
-
const { port, version } = container
|
|
962
|
-
const db = options.database || container.database
|
|
963
|
-
|
|
964
|
-
if (!db) {
|
|
965
|
-
throw new Error(
|
|
966
|
-
'Database name is required. Specify --database or set a default database on the container.',
|
|
967
|
-
)
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
const consolePath = await this.getConsolePath(version)
|
|
971
|
-
|
|
972
|
-
if (options.file) {
|
|
973
|
-
// Run TypeQL script file
|
|
974
|
-
const args = [...getConsoleBaseArgs(port), '--script', options.file]
|
|
975
|
-
|
|
976
|
-
await new Promise<void>((resolve, reject) => {
|
|
977
|
-
const proc = spawn(consolePath, args, {
|
|
978
|
-
stdio: 'inherit',
|
|
979
|
-
})
|
|
980
|
-
|
|
981
|
-
proc.on('error', reject)
|
|
982
|
-
proc.on('close', (code, signal) => {
|
|
983
|
-
if (code === 0) resolve()
|
|
984
|
-
else if (code === null)
|
|
985
|
-
reject(new Error(`typedb console was killed by signal ${signal}`))
|
|
986
|
-
else reject(new Error(`typedb console exited with code ${code}`))
|
|
987
|
-
})
|
|
988
|
-
})
|
|
989
|
-
} else if (options.sql) {
|
|
990
|
-
// Run inline TypeQL via temp script file
|
|
991
|
-
// TypeDB console --command mode doesn't support multi-step transaction flows;
|
|
992
|
-
// each --command is a standalone top-level command. Transactions require --script.
|
|
993
|
-
const upperSql = options.sql.trim().toUpperCase()
|
|
994
|
-
let txType: 'read' | 'write' | 'schema'
|
|
995
|
-
if (options.transactionType) {
|
|
996
|
-
txType = options.transactionType
|
|
997
|
-
} else if (
|
|
998
|
-
upperSql.startsWith('DEFINE') ||
|
|
999
|
-
upperSql.startsWith('UNDEFINE')
|
|
1000
|
-
) {
|
|
1001
|
-
txType = 'schema'
|
|
1002
|
-
} else {
|
|
1003
|
-
txType = 'write'
|
|
1004
|
-
}
|
|
1005
|
-
const txEnd = txType === 'read' ? 'close' : 'commit'
|
|
1006
|
-
const scriptContent = `transaction ${txType} ${db}\n\n${options.sql}\n\n${txEnd}\n`
|
|
1007
|
-
const tempScript = join(
|
|
1008
|
-
tmpdir(),
|
|
1009
|
-
`spindb-typedb-${Date.now()}-${Math.random().toString(36).slice(2)}.tqls`,
|
|
1010
|
-
)
|
|
1011
|
-
|
|
1012
|
-
try {
|
|
1013
|
-
await writeFile(tempScript, scriptContent, 'utf-8')
|
|
1014
|
-
|
|
1015
|
-
const args = [...getConsoleBaseArgs(port), '--script', tempScript]
|
|
1016
|
-
|
|
1017
|
-
await new Promise<void>((resolve, reject) => {
|
|
1018
|
-
const proc = spawn(consolePath, args, {
|
|
1019
|
-
stdio: 'inherit',
|
|
1020
|
-
})
|
|
1021
|
-
|
|
1022
|
-
proc.on('error', reject)
|
|
1023
|
-
proc.on('close', (code, signal) => {
|
|
1024
|
-
if (code === 0) resolve()
|
|
1025
|
-
else if (code === null)
|
|
1026
|
-
reject(new Error(`typedb console was killed by signal ${signal}`))
|
|
1027
|
-
else reject(new Error(`typedb console exited with code ${code}`))
|
|
1028
|
-
})
|
|
1029
|
-
})
|
|
1030
|
-
} finally {
|
|
1031
|
-
await unlink(tempScript).catch(() => {})
|
|
1032
|
-
}
|
|
1033
|
-
} else {
|
|
1034
|
-
throw new Error('Either file or sql option must be provided')
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
* Execute a TypeQL query and return structured results
|
|
1040
|
-
* TypeDB doesn't return tabular results like SQL, but we normalize the output
|
|
1041
|
-
*/
|
|
1042
|
-
async executeQuery(
|
|
1043
|
-
container: ContainerConfig,
|
|
1044
|
-
query: string,
|
|
1045
|
-
_options?: QueryOptions,
|
|
1046
|
-
): Promise<QueryResult> {
|
|
1047
|
-
const { port, version } = container
|
|
1048
|
-
const db = container.database
|
|
1049
|
-
|
|
1050
|
-
if (!db) {
|
|
1051
|
-
throw new Error(
|
|
1052
|
-
'Database name is required. Specify --database or set a default database on the container.',
|
|
1053
|
-
)
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
const consolePath = await this.getConsolePath(version)
|
|
1057
|
-
|
|
1058
|
-
// TypeDB console --command mode doesn't support multi-step transaction flows;
|
|
1059
|
-
// each --command is a standalone top-level command. Use temp script for queries.
|
|
1060
|
-
const scriptContent = `transaction read ${db}\n\n${query}\n\nclose\n`
|
|
1061
|
-
const tempScript = join(
|
|
1062
|
-
tmpdir(),
|
|
1063
|
-
`spindb-typedb-query-${Date.now()}-${Math.random().toString(36).slice(2)}.tqls`,
|
|
1064
|
-
)
|
|
1065
|
-
|
|
1066
|
-
try {
|
|
1067
|
-
await writeFile(tempScript, scriptContent, 'utf-8')
|
|
1068
|
-
|
|
1069
|
-
return await new Promise((resolve, reject) => {
|
|
1070
|
-
const args = [...getConsoleBaseArgs(port), '--script', tempScript]
|
|
1071
|
-
|
|
1072
|
-
const proc = spawn(consolePath, args, {
|
|
1073
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1074
|
-
})
|
|
1075
|
-
|
|
1076
|
-
let stdout = ''
|
|
1077
|
-
let stderr = ''
|
|
1078
|
-
|
|
1079
|
-
proc.stdout?.on('data', (data: Buffer) => {
|
|
1080
|
-
stdout += data.toString()
|
|
1081
|
-
})
|
|
1082
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
1083
|
-
stderr += data.toString()
|
|
1084
|
-
})
|
|
1085
|
-
|
|
1086
|
-
const timeout = setTimeout(() => {
|
|
1087
|
-
proc.kill('SIGTERM')
|
|
1088
|
-
reject(new Error('Query timed out after 60 seconds'))
|
|
1089
|
-
}, 60000)
|
|
1090
|
-
|
|
1091
|
-
proc.on('error', (err) => {
|
|
1092
|
-
clearTimeout(timeout)
|
|
1093
|
-
reject(err)
|
|
1094
|
-
})
|
|
1095
|
-
|
|
1096
|
-
proc.on('close', (code) => {
|
|
1097
|
-
clearTimeout(timeout)
|
|
1098
|
-
if (code !== 0) {
|
|
1099
|
-
reject(
|
|
1100
|
-
new Error(stderr || `typedb console exited with code ${code}`),
|
|
1101
|
-
)
|
|
1102
|
-
return
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
// TypeDB console output is not tabular - return raw output as a single result
|
|
1106
|
-
resolve({
|
|
1107
|
-
columns: ['result'],
|
|
1108
|
-
rows: [{ result: stdout.trim() }],
|
|
1109
|
-
rowCount: 1,
|
|
1110
|
-
})
|
|
1111
|
-
})
|
|
1112
|
-
})
|
|
1113
|
-
} finally {
|
|
1114
|
-
await unlink(tempScript).catch(() => {})
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
/**
|
|
1119
|
-
* List all databases
|
|
1120
|
-
* Uses TypeDB console 'database list' command
|
|
1121
|
-
*/
|
|
1122
|
-
async listDatabases(container: ContainerConfig): Promise<string[]> {
|
|
1123
|
-
const { port, version } = container
|
|
1124
|
-
const consolePath = await this.getConsolePath(version)
|
|
1125
|
-
|
|
1126
|
-
return new Promise((resolve, reject) => {
|
|
1127
|
-
const args = [...getConsoleBaseArgs(port), '--command', 'database list']
|
|
1128
|
-
|
|
1129
|
-
const proc = spawn(consolePath, args, {
|
|
1130
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1131
|
-
})
|
|
1132
|
-
|
|
1133
|
-
let stdout = ''
|
|
1134
|
-
let stderr = ''
|
|
1135
|
-
|
|
1136
|
-
proc.stdout?.on('data', (data: Buffer) => {
|
|
1137
|
-
stdout += data.toString()
|
|
1138
|
-
})
|
|
1139
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
1140
|
-
stderr += data.toString()
|
|
1141
|
-
})
|
|
1142
|
-
|
|
1143
|
-
proc.on('error', reject)
|
|
1144
|
-
|
|
1145
|
-
proc.on('close', (code) => {
|
|
1146
|
-
if (code !== 0) {
|
|
1147
|
-
reject(new Error(stderr || `typedb console exited with code ${code}`))
|
|
1148
|
-
return
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
try {
|
|
1152
|
-
// Parse database list output
|
|
1153
|
-
// Each line after the command echo is a database name
|
|
1154
|
-
const lines = stdout
|
|
1155
|
-
.split('\n')
|
|
1156
|
-
.map((l) => l.trim())
|
|
1157
|
-
.filter(Boolean)
|
|
1158
|
-
|
|
1159
|
-
// Filter out command echoes (+ prefix) and prompts
|
|
1160
|
-
const databases = lines.filter(
|
|
1161
|
-
(line) =>
|
|
1162
|
-
!line.startsWith('+') &&
|
|
1163
|
-
!line.startsWith('>') &&
|
|
1164
|
-
!line.startsWith('database') &&
|
|
1165
|
-
!line.includes('connected') &&
|
|
1166
|
-
line.length > 0,
|
|
1167
|
-
)
|
|
1168
|
-
|
|
1169
|
-
resolve(
|
|
1170
|
-
databases.length > 0
|
|
1171
|
-
? databases
|
|
1172
|
-
: container.database
|
|
1173
|
-
? [container.database]
|
|
1174
|
-
: [],
|
|
1175
|
-
)
|
|
1176
|
-
} catch {
|
|
1177
|
-
resolve(container.database ? [container.database] : [])
|
|
1178
|
-
}
|
|
1179
|
-
})
|
|
1180
|
-
})
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
/**
|
|
1184
|
-
* Create a TypeDB user via console `user create` command.
|
|
1185
|
-
* TypeDB 3.x has built-in user management with password authentication.
|
|
1186
|
-
*/
|
|
1187
|
-
async createUser(
|
|
1188
|
-
container: ContainerConfig,
|
|
1189
|
-
options: CreateUserOptions,
|
|
1190
|
-
): Promise<UserCredentials> {
|
|
1191
|
-
const { username, password } = options
|
|
1192
|
-
assertValidUsername(username)
|
|
1193
|
-
const { port, version } = container
|
|
1194
|
-
|
|
1195
|
-
const consolePath = await this.getConsolePath(version)
|
|
1196
|
-
|
|
1197
|
-
const args = [
|
|
1198
|
-
...getConsoleBaseArgs(port),
|
|
1199
|
-
'--command',
|
|
1200
|
-
`user create ${username} ${password}`,
|
|
1201
|
-
]
|
|
1202
|
-
|
|
1203
|
-
await new Promise<void>((resolve, reject) => {
|
|
1204
|
-
const proc = spawn(consolePath, args, {
|
|
1205
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1206
|
-
})
|
|
1207
|
-
|
|
1208
|
-
let stderr = ''
|
|
1209
|
-
proc.stderr?.on('data', (data: Buffer) => {
|
|
1210
|
-
stderr += data.toString()
|
|
1211
|
-
})
|
|
1212
|
-
|
|
1213
|
-
proc.on('close', async (code) => {
|
|
1214
|
-
if (code === 0) {
|
|
1215
|
-
logDebug(`Created TypeDB user: ${username}`)
|
|
1216
|
-
resolve()
|
|
1217
|
-
} else if (stderr.toLowerCase().includes('already exists')) {
|
|
1218
|
-
// User exists - update password instead
|
|
1219
|
-
logDebug(`User "${username}" already exists, updating password`)
|
|
1220
|
-
try {
|
|
1221
|
-
const updateArgs = [
|
|
1222
|
-
...getConsoleBaseArgs(port),
|
|
1223
|
-
'--command',
|
|
1224
|
-
`user password-update ${username} ${password}`,
|
|
1225
|
-
]
|
|
1226
|
-
await new Promise<void>((res, rej) => {
|
|
1227
|
-
const updateProc = spawn(consolePath, updateArgs, {
|
|
1228
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1229
|
-
})
|
|
1230
|
-
let updateStderr = ''
|
|
1231
|
-
updateProc.stderr?.on('data', (data: Buffer) => {
|
|
1232
|
-
updateStderr += data.toString()
|
|
1233
|
-
})
|
|
1234
|
-
updateProc.on('close', (updateCode) => {
|
|
1235
|
-
if (updateCode === 0) {
|
|
1236
|
-
logDebug(`Updated password for TypeDB user: ${username}`)
|
|
1237
|
-
res()
|
|
1238
|
-
} else {
|
|
1239
|
-
rej(
|
|
1240
|
-
new Error(
|
|
1241
|
-
`Failed to update user password: ${updateStderr}`,
|
|
1242
|
-
),
|
|
1243
|
-
)
|
|
1244
|
-
}
|
|
1245
|
-
})
|
|
1246
|
-
updateProc.on('error', rej)
|
|
1247
|
-
})
|
|
1248
|
-
resolve()
|
|
1249
|
-
} catch (error) {
|
|
1250
|
-
reject(error)
|
|
1251
|
-
}
|
|
1252
|
-
} else {
|
|
1253
|
-
reject(new Error(`Failed to create user: ${stderr}`))
|
|
1254
|
-
}
|
|
1255
|
-
})
|
|
1256
|
-
proc.on('error', reject)
|
|
1257
|
-
})
|
|
1258
|
-
|
|
1259
|
-
const connectionString = `typedb://${encodeURIComponent(username)}:${encodeURIComponent(password)}@127.0.0.1:${port}`
|
|
1260
|
-
|
|
1261
|
-
return {
|
|
1262
|
-
username,
|
|
1263
|
-
password,
|
|
1264
|
-
connectionString,
|
|
1265
|
-
engine: container.engine,
|
|
1266
|
-
container: container.name,
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
async getTypeDBConsolePath(version?: string): Promise<string> {
|
|
1271
|
-
return requireTypeDBConsolePath(version)
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
export const typedbEngine = new TypeDBEngine()
|