spindb 0.32.2 → 0.34.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.
Files changed (41) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +112 -855
  3. package/cli/commands/connect.ts +99 -0
  4. package/cli/commands/create.ts +5 -1
  5. package/cli/commands/engines.ts +78 -1
  6. package/cli/commands/menu/backup-handlers.ts +9 -0
  7. package/cli/commands/menu/container-handlers.ts +41 -12
  8. package/cli/commands/menu/engine-handlers.ts +4 -0
  9. package/cli/commands/menu/index.ts +72 -1
  10. package/cli/commands/menu/settings-handlers.ts +3 -0
  11. package/cli/commands/menu/shell-handlers.ts +592 -12
  12. package/cli/commands/ports.ts +211 -0
  13. package/cli/constants.ts +7 -3
  14. package/cli/helpers.ts +73 -0
  15. package/cli/index.ts +2 -0
  16. package/cli/ui/prompts.ts +4 -2
  17. package/config/backup-formats.ts +14 -0
  18. package/config/engine-defaults.ts +13 -0
  19. package/config/engines.json +17 -0
  20. package/core/config-manager.ts +18 -0
  21. package/core/dblab-utils.ts +113 -0
  22. package/core/dependency-manager.ts +6 -0
  23. package/core/docker-exporter.ts +13 -0
  24. package/core/pgweb-utils.ts +62 -0
  25. package/engines/base-engine.ts +9 -0
  26. package/engines/cockroachdb/index.ts +3 -0
  27. package/engines/ferretdb/index.ts +46 -27
  28. package/engines/index.ts +4 -0
  29. package/engines/influxdb/README.md +180 -0
  30. package/engines/influxdb/api-client.ts +64 -0
  31. package/engines/influxdb/backup.ts +160 -0
  32. package/engines/influxdb/binary-manager.ts +110 -0
  33. package/engines/influxdb/binary-urls.ts +69 -0
  34. package/engines/influxdb/hostdb-releases.ts +23 -0
  35. package/engines/influxdb/index.ts +1227 -0
  36. package/engines/influxdb/restore.ts +417 -0
  37. package/engines/influxdb/version-maps.ts +75 -0
  38. package/engines/influxdb/version-validator.ts +128 -0
  39. package/engines/postgresql/index.ts +3 -0
  40. package/package.json +2 -1
  41. package/types/index.ts +17 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * InfluxDB Binary Manager
3
+ *
4
+ * Handles downloading, extracting, and managing InfluxDB binaries from hostdb.
5
+ * Extends BaseBinaryManager for shared download/extraction logic.
6
+ *
7
+ * InfluxDB 3.x archives extract to a flat `influxdb/` directory:
8
+ * influxdb/
9
+ * ├── influxdb3 (server binary)
10
+ * ├── python/ (bundled Python runtime)
11
+ * │ └── lib/
12
+ * │ └── libpython3.13.dylib
13
+ * ├── LICENSE-APACHE
14
+ * └── LICENSE-MIT
15
+ *
16
+ * The binary uses @executable_path/python/lib/libpython3.13.dylib, so python/
17
+ * must be in the same directory as the binary. We reorganize to:
18
+ * bin/
19
+ * ├── influxdb3
20
+ * └── python/ (co-located for @executable_path resolution)
21
+ */
22
+
23
+ import { mkdir, readdir } from 'fs/promises'
24
+ import { join } from 'path'
25
+ import {
26
+ BaseBinaryManager,
27
+ type BinaryManagerConfig,
28
+ } from '../../core/base-binary-manager'
29
+ import { moveEntry } from '../../core/fs-error-utils'
30
+ import { logDebug } from '../../core/error-handler'
31
+ import { getBinaryUrl } from './binary-urls'
32
+ import { normalizeVersion } from './version-maps'
33
+ import { Engine, type Platform, type Arch } from '../../types'
34
+
35
+ class InfluxDBBinaryManager extends BaseBinaryManager {
36
+ protected readonly config: BinaryManagerConfig = {
37
+ engine: Engine.InfluxDB,
38
+ engineName: 'influxdb',
39
+ displayName: 'InfluxDB',
40
+ serverBinary: 'influxdb3',
41
+ }
42
+
43
+ protected getBinaryUrlFromModule(
44
+ version: string,
45
+ platform: Platform,
46
+ arch: Arch,
47
+ ): string {
48
+ return getBinaryUrl(version, platform, arch)
49
+ }
50
+
51
+ protected normalizeVersionFromModule(version: string): string {
52
+ return normalizeVersion(version)
53
+ }
54
+
55
+ protected parseVersionFromOutput(stdout: string): string | null {
56
+ // Extract version from output like "influxdb3 3.8.0" or "InfluxDB 3 Edge v3.8.0"
57
+ const match = stdout.match(/v?(\d+\.\d+\.\d+)/)
58
+ return match?.[1] ?? null
59
+ }
60
+
61
+ /**
62
+ * Override moveExtractedEntries to co-locate python/ with the binary.
63
+ *
64
+ * The influxdb3 binary references @executable_path/python/lib/libpython3.13.dylib,
65
+ * so the python/ directory must be inside bin/ alongside the binary.
66
+ * The default flat-structure handler would put python/ at binPath/python/ instead
67
+ * of binPath/bin/python/, causing a dylib load failure.
68
+ */
69
+ protected override async moveExtractedEntries(
70
+ extractDir: string,
71
+ binPath: string,
72
+ ): Promise<void> {
73
+ const entries = await readdir(extractDir, { withFileTypes: true })
74
+
75
+ // Find the influxdb directory (e.g., "influxdb" or "influxdb-3.8.0")
76
+ const influxDir = entries.find(
77
+ (e) =>
78
+ e.isDirectory() &&
79
+ (e.name === 'influxdb' || e.name.startsWith('influxdb-')),
80
+ )
81
+
82
+ const sourceDir = influxDir ? join(extractDir, influxDir.name) : extractDir
83
+ const sourceEntries = influxDir
84
+ ? await readdir(sourceDir, { withFileTypes: true })
85
+ : entries
86
+
87
+ // Create bin/ directory
88
+ const destBinDir = join(binPath, 'bin')
89
+ await mkdir(destBinDir, { recursive: true })
90
+
91
+ for (const entry of sourceEntries) {
92
+ const sourcePath = join(sourceDir, entry.name)
93
+
94
+ if (entry.name === 'influxdb3' || entry.name === 'influxdb3.exe') {
95
+ // Server binary → bin/
96
+ await moveEntry(sourcePath, join(destBinDir, entry.name))
97
+ } else if (entry.name === 'python') {
98
+ // Python runtime → bin/python/ (must be co-located with binary for @executable_path)
99
+ await moveEntry(sourcePath, join(destBinDir, 'python'))
100
+ } else {
101
+ // Licenses, metadata, etc. → binPath root
102
+ await moveEntry(sourcePath, join(binPath, entry.name))
103
+ }
104
+ }
105
+
106
+ logDebug('InfluxDB binaries reorganized with python/ co-located in bin/')
107
+ }
108
+ }
109
+
110
+ export const influxdbBinaryManager = new InfluxDBBinaryManager()
@@ -0,0 +1,69 @@
1
+ import { normalizeVersion } from './version-maps'
2
+ import { buildHostdbUrl } from '../../core/hostdb-client'
3
+ import { Engine, Platform, type Arch } from '../../types'
4
+
5
+ /**
6
+ * Supported platform identifiers for hostdb downloads.
7
+ * hostdb uses standard Node.js platform naming - this set validates
8
+ * that a platform/arch combination is supported, not transforms it.
9
+ */
10
+ const SUPPORTED_PLATFORMS = new Set([
11
+ 'darwin-arm64',
12
+ 'darwin-x64',
13
+ 'linux-arm64',
14
+ 'linux-x64',
15
+ 'win32-x64',
16
+ ])
17
+
18
+ /**
19
+ * Get the hostdb platform identifier
20
+ *
21
+ * hostdb uses standard platform naming that matches Node.js identifiers directly.
22
+ * This function validates the platform/arch combination is supported.
23
+ *
24
+ * @param platform - Node.js platform (e.g., 'darwin', 'linux', 'win32')
25
+ * @param arch - Node.js architecture (e.g., 'arm64', 'x64')
26
+ * @returns hostdb platform identifier or null if unsupported
27
+ */
28
+ export function getHostdbPlatform(
29
+ platform: Platform,
30
+ arch: Arch,
31
+ ): string | null {
32
+ const key = `${platform}-${arch}`
33
+ return SUPPORTED_PLATFORMS.has(key) ? key : null
34
+ }
35
+
36
+ /**
37
+ * Build the download URL for InfluxDB binaries from hostdb
38
+ *
39
+ * Format: https://github.com/robertjbass/hostdb/releases/download/influxdb-{version}/influxdb-{version}-{platform}-{arch}.{ext}
40
+ *
41
+ * @param version - InfluxDB version (e.g., '3', '3.8.0')
42
+ * @param platform - Platform identifier (e.g., 'darwin', 'linux', 'win32')
43
+ * @param arch - Architecture identifier (e.g., 'arm64', 'x64')
44
+ * @returns Download URL for the binary
45
+ */
46
+ export function getBinaryUrl(
47
+ version: string,
48
+ platform: Platform,
49
+ arch: Arch,
50
+ ): string {
51
+ const platformKey = `${platform}-${arch}`
52
+ const hostdbPlatform = getHostdbPlatform(platform, arch)
53
+ if (!hostdbPlatform) {
54
+ const supported = Array.from(SUPPORTED_PLATFORMS).join(', ')
55
+ throw new Error(
56
+ `Unsupported platform: ${platformKey}. Supported platforms: ${supported}`,
57
+ )
58
+ }
59
+
60
+ // Normalize version (handles major version lookup and X.Y -> X.Y.Z conversion)
61
+ const fullVersion = normalizeVersion(version)
62
+ const ext = platform === Platform.Win32 ? 'zip' : 'tar.gz'
63
+
64
+ return buildHostdbUrl(Engine.InfluxDB, {
65
+ version: fullVersion,
66
+ hostdbPlatform,
67
+ extension: ext,
68
+ })
69
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * hostdb Releases Module for InfluxDB
3
+ *
4
+ * Fetches InfluxDB binary information from the hostdb repository at
5
+ * https://github.com/robertjbass/hostdb
6
+ */
7
+
8
+ import { createHostdbReleases } from '../../core/hostdb-releases-factory'
9
+ import { INFLUXDB_VERSION_MAP, SUPPORTED_MAJOR_VERSIONS } from './version-maps'
10
+ import { influxdbBinaryManager } from './binary-manager'
11
+ import { Engine } from '../../types'
12
+
13
+ const hostdbReleases = createHostdbReleases({
14
+ engine: Engine.InfluxDB,
15
+ displayName: 'InfluxDB',
16
+ versionMap: INFLUXDB_VERSION_MAP,
17
+ supportedMajorVersions: SUPPORTED_MAJOR_VERSIONS,
18
+ groupingStrategy: 'single-digit',
19
+ listInstalled: () => influxdbBinaryManager.listInstalled(),
20
+ })
21
+
22
+ export const fetchAvailableVersions = hostdbReleases.fetchAvailableVersions
23
+ export const getLatestVersion = hostdbReleases.getLatestVersion