spindb 0.34.5 → 0.35.2

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 (49) hide show
  1. package/README.md +4 -4
  2. package/cli/commands/create.ts +22 -1
  3. package/cli/commands/engines.ts +51 -21
  4. package/cli/commands/menu/container-handlers.ts +17 -1
  5. package/cli/commands/menu/engine-handlers.ts +48 -29
  6. package/cli/ui/theme.ts +5 -2
  7. package/config/engines.json +2 -2
  8. package/core/base-binary-manager.ts +6 -2
  9. package/core/base-document-binary-manager.ts +5 -2
  10. package/core/base-embedded-binary-manager.ts +5 -2
  11. package/core/base-server-binary-manager.ts +5 -2
  12. package/core/hostdb-client.ts +157 -22
  13. package/core/hostdb-metadata.ts +67 -43
  14. package/engines/clickhouse/binary-urls.ts +1 -1
  15. package/engines/cockroachdb/binary-urls.ts +9 -7
  16. package/engines/cockroachdb/hostdb-releases.ts +18 -106
  17. package/engines/cockroachdb/version-maps.ts +1 -1
  18. package/engines/couchdb/binary-urls.ts +1 -1
  19. package/engines/duckdb/binary-urls.ts +1 -1
  20. package/engines/duckdb/index.ts +4 -74
  21. package/engines/ferretdb/README.md +76 -38
  22. package/engines/ferretdb/backup.ts +18 -10
  23. package/engines/ferretdb/binary-manager.ts +233 -35
  24. package/engines/ferretdb/binary-urls.ts +69 -24
  25. package/engines/ferretdb/index.ts +424 -213
  26. package/engines/ferretdb/restore.ts +23 -16
  27. package/engines/ferretdb/version-maps.ts +36 -8
  28. package/engines/index.ts +3 -4
  29. package/engines/influxdb/binary-urls.ts +1 -1
  30. package/engines/mariadb/binary-urls.ts +2 -2
  31. package/engines/meilisearch/binary-urls.ts +1 -1
  32. package/engines/mysql/binary-urls.ts +2 -2
  33. package/engines/postgresql/binary-urls.ts +1 -1
  34. package/engines/qdrant/binary-urls.ts +1 -1
  35. package/engines/questdb/binary-manager.ts +16 -9
  36. package/engines/questdb/binary-urls.ts +9 -10
  37. package/engines/questdb/hostdb-releases.ts +19 -97
  38. package/engines/questdb/version-maps.ts +2 -2
  39. package/engines/redis/binary-urls.ts +1 -8
  40. package/engines/sqlite/binary-urls.ts +1 -1
  41. package/engines/sqlite/index.ts +4 -74
  42. package/engines/surrealdb/binary-urls.ts +9 -7
  43. package/engines/surrealdb/hostdb-releases.ts +18 -106
  44. package/engines/surrealdb/version-maps.ts +1 -1
  45. package/engines/typedb/binary-urls.ts +10 -8
  46. package/engines/typedb/hostdb-releases.ts +18 -113
  47. package/engines/typedb/version-maps.ts +1 -1
  48. package/engines/valkey/binary-urls.ts +1 -1
  49. package/package.json +4 -1
@@ -1,111 +1,23 @@
1
1
  /**
2
- * SurrealDB hostdb releases integration
2
+ * hostdb Releases Module for SurrealDB
3
3
  *
4
- * Fetches available versions from hostdb releases.json and provides
5
- * fallback to local version maps.
4
+ * Fetches SurrealDB binary information from the hostdb repository at
5
+ * https://github.com/robertjbass/hostdb
6
6
  */
7
7
 
8
- import { logDebug } from '../../core/error-handler'
8
+ import { createHostdbReleases } from '../../core/hostdb-releases-factory'
9
9
  import { SURREALDB_VERSION_MAP, SUPPORTED_MAJOR_VERSIONS } from './version-maps'
10
-
11
- const HOSTDB_RELEASES_URL =
12
- 'https://raw.githubusercontent.com/robertjbass/hostdb/main/releases.json'
13
-
14
- // Cache for fetched versions (expires after 5 minutes)
15
- let cachedVersions: Record<string, string[]> | null = null
16
- let cacheExpiry = 0
17
- const CACHE_TTL_MS = 5 * 60 * 1000
18
-
19
- type HostdbReleases = {
20
- [engine: string]: {
21
- versions: {
22
- version: string
23
- platforms: string[]
24
- }[]
25
- }
26
- }
27
-
28
- /**
29
- * Fetch available SurrealDB versions from hostdb
30
- * Returns a map of major version to available patch versions
31
- *
32
- * Falls back to local version maps if fetch fails
33
- */
34
- export async function fetchAvailableVersions(): Promise<
35
- Record<string, string[]>
36
- > {
37
- // Return cached versions if still valid
38
- if (cachedVersions && Date.now() < cacheExpiry) {
39
- return cachedVersions
40
- }
41
-
42
- try {
43
- const response = await fetch(HOSTDB_RELEASES_URL)
44
- if (!response.ok) {
45
- throw new Error(`HTTP ${response.status}`)
46
- }
47
-
48
- const releases = (await response.json()) as HostdbReleases
49
- const surrealdbReleases = releases.surrealdb
50
-
51
- if (!surrealdbReleases?.versions) {
52
- throw new Error('No SurrealDB versions found in releases.json')
53
- }
54
-
55
- // Group versions by major version
56
- const versionMap: Record<string, string[]> = {}
57
-
58
- for (const { version } of surrealdbReleases.versions) {
59
- // Extract major version (e.g., "2" from "2.3.2")
60
- const majorMatch = version.match(/^(\d+)/)
61
- if (!majorMatch) continue
62
-
63
- const majorVersion = majorMatch[1]
64
- if (!versionMap[majorVersion]) {
65
- versionMap[majorVersion] = []
66
- }
67
- versionMap[majorVersion].push(version)
68
- }
69
-
70
- // Sort versions within each major version (newest first)
71
- for (const major of Object.keys(versionMap)) {
72
- versionMap[major].sort((a, b) => {
73
- const partsA = a.split('.').map(Number)
74
- const partsB = b.split('.').map(Number)
75
- for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
76
- const diff = (partsB[i] || 0) - (partsA[i] || 0)
77
- if (diff !== 0) return diff
78
- }
79
- return 0
80
- })
81
- }
82
-
83
- // Cache the results
84
- cachedVersions = versionMap
85
- cacheExpiry = Date.now() + CACHE_TTL_MS
86
-
87
- logDebug('Fetched SurrealDB versions from hostdb', { versionMap })
88
- return versionMap
89
- } catch (error) {
90
- logDebug(`Failed to fetch hostdb releases: ${error}`)
91
-
92
- // Fall back to local version maps
93
- const fallbackMap: Record<string, string[]> = {}
94
- for (const major of SUPPORTED_MAJOR_VERSIONS) {
95
- const fullVersion = SURREALDB_VERSION_MAP[major]
96
- if (fullVersion) {
97
- fallbackMap[major] = [fullVersion]
98
- }
99
- }
100
-
101
- return fallbackMap
102
- }
103
- }
104
-
105
- /**
106
- * Clear the version cache (useful for testing)
107
- */
108
- export function clearVersionCache(): void {
109
- cachedVersions = null
110
- cacheExpiry = 0
111
- }
10
+ import { surrealdbBinaryManager } from './binary-manager'
11
+ import { Engine } from '../../types'
12
+
13
+ const hostdbReleases = createHostdbReleases({
14
+ engine: Engine.SurrealDB,
15
+ displayName: 'SurrealDB',
16
+ versionMap: SURREALDB_VERSION_MAP,
17
+ supportedMajorVersions: SUPPORTED_MAJOR_VERSIONS,
18
+ groupingStrategy: 'single-digit',
19
+ listInstalled: () => surrealdbBinaryManager.listInstalled(),
20
+ })
21
+
22
+ export const fetchAvailableVersions = hostdbReleases.fetchAvailableVersions
23
+ export const getLatestVersion = hostdbReleases.getLatestVersion
@@ -2,7 +2,7 @@
2
2
  * SurrealDB version mapping
3
3
  *
4
4
  * Maps short version aliases to full versions from hostdb releases.
5
- * MUST stay in sync with hostdb releases.json
5
+ * MUST stay in sync with hostdb databases.json
6
6
  */
7
7
 
8
8
  // Full version map for SurrealDB
@@ -1,19 +1,17 @@
1
1
  /**
2
2
  * TypeDB binary URL generation
3
3
  *
4
- * Generates download URLs for TypeDB binaries from hostdb.
4
+ * Generates download URLs for TypeDB binaries from the layerbase registry.
5
5
  */
6
6
 
7
- import type { Platform, Arch } from '../../types'
7
+ import { type Platform, type Arch, Engine } from '../../types'
8
8
  import { normalizeVersion } from './version-maps'
9
-
10
- const HOSTDB_BASE_URL =
11
- 'https://github.com/robertjbass/hostdb/releases/download'
9
+ import { buildHostdbUrl } from '../../core/hostdb-client'
12
10
 
13
11
  /**
14
12
  * Get the binary download URL for a specific version and platform
15
13
  *
16
- * URL format: https://github.com/robertjbass/hostdb/releases/download/typedb-{version}/typedb-{version}-{platform}-{arch}.{ext}
14
+ * URL format: https://registry.layerbase.host/typedb-{version}/typedb-{version}-{platform}-{arch}.{ext}
17
15
  *
18
16
  * @param version - TypeDB version (e.g., '3.8.0' or '3')
19
17
  * @param platform - Target platform (darwin, linux, win32)
@@ -27,12 +25,16 @@ export function getBinaryUrl(
27
25
  const fullVersion = normalizeVersion(version)
28
26
  const ext = getArchiveExtension(platform)
29
27
 
30
- return `${HOSTDB_BASE_URL}/typedb-${fullVersion}/typedb-${fullVersion}-${platform}-${arch}.${ext}`
28
+ return buildHostdbUrl(Engine.TypeDB, {
29
+ version: fullVersion,
30
+ hostdbPlatform: `${platform}-${arch}`,
31
+ extension: ext,
32
+ })
31
33
  }
32
34
 
33
35
  /**
34
36
  * Get the archive extension for a platform
35
37
  */
36
- export function getArchiveExtension(platform: Platform): string {
38
+ export function getArchiveExtension(platform: Platform): 'tar.gz' | 'zip' {
37
39
  return platform === 'win32' ? 'zip' : 'tar.gz'
38
40
  }
@@ -1,118 +1,23 @@
1
1
  /**
2
- * TypeDB hostdb releases integration
2
+ * hostdb Releases Module for TypeDB
3
3
  *
4
- * Fetches available versions from hostdb releases.json and provides
5
- * fallback to local version maps.
4
+ * Fetches TypeDB binary information from the hostdb repository at
5
+ * https://github.com/robertjbass/hostdb
6
6
  */
7
7
 
8
- import { logDebug } from '../../core/error-handler'
8
+ import { createHostdbReleases } from '../../core/hostdb-releases-factory'
9
9
  import { TYPEDB_VERSION_MAP, SUPPORTED_MAJOR_VERSIONS } from './version-maps'
10
-
11
- const HOSTDB_RELEASES_URL =
12
- 'https://raw.githubusercontent.com/robertjbass/hostdb/main/releases.json'
13
-
14
- // Cache for fetched versions (expires after 5 minutes)
15
- let cachedVersions: Record<string, string[]> | null = null
16
- let cacheExpiry = 0
17
- const CACHE_TTL_MS = 5 * 60 * 1000
18
-
19
- type HostdbReleases = {
20
- [engine: string]: {
21
- versions: {
22
- version: string
23
- platforms: string[]
24
- }[]
25
- }
26
- }
27
-
28
- /**
29
- * Fetch available TypeDB versions from hostdb
30
- * Returns a map of major version to available patch versions
31
- *
32
- * Falls back to local version maps if fetch fails
33
- */
34
- export async function fetchAvailableVersions(): Promise<
35
- Record<string, string[]>
36
- > {
37
- // Return cached versions if still valid
38
- if (cachedVersions && Date.now() < cacheExpiry) {
39
- return cachedVersions
40
- }
41
-
42
- try {
43
- const controller = new AbortController()
44
- const timeoutId = setTimeout(() => controller.abort(), 10000)
45
- let response: Response
46
- try {
47
- response = await fetch(HOSTDB_RELEASES_URL, { signal: controller.signal })
48
- } finally {
49
- clearTimeout(timeoutId)
50
- }
51
- if (!response.ok) {
52
- throw new Error(`HTTP ${response.status}`)
53
- }
54
-
55
- const releases = (await response.json()) as HostdbReleases
56
- const typedbReleases = releases.typedb
57
-
58
- if (!typedbReleases?.versions) {
59
- throw new Error('No TypeDB versions found in releases.json')
60
- }
61
-
62
- // Group versions by major version
63
- const versionMap: Record<string, string[]> = {}
64
-
65
- for (const { version } of typedbReleases.versions) {
66
- // Extract major version (e.g., "3" from "3.8.0")
67
- const majorMatch = version.match(/^(\d+)/)
68
- if (!majorMatch) continue
69
-
70
- const majorVersion = majorMatch[1]
71
- if (!versionMap[majorVersion]) {
72
- versionMap[majorVersion] = []
73
- }
74
- versionMap[majorVersion].push(version)
75
- }
76
-
77
- // Sort versions within each major version (newest first)
78
- for (const major of Object.keys(versionMap)) {
79
- versionMap[major].sort((a, b) => {
80
- const partsA = a.split('.').map(Number)
81
- const partsB = b.split('.').map(Number)
82
- for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
83
- const diff = (partsB[i] || 0) - (partsA[i] || 0)
84
- if (diff !== 0) return diff
85
- }
86
- return 0
87
- })
88
- }
89
-
90
- // Cache the results
91
- cachedVersions = versionMap
92
- cacheExpiry = Date.now() + CACHE_TTL_MS
93
-
94
- logDebug('Fetched TypeDB versions from hostdb', { versionMap })
95
- return versionMap
96
- } catch (error) {
97
- logDebug(`Failed to fetch hostdb releases: ${error}`)
98
-
99
- // Fall back to local version maps
100
- const fallbackMap: Record<string, string[]> = {}
101
- for (const major of SUPPORTED_MAJOR_VERSIONS) {
102
- const fullVersion = TYPEDB_VERSION_MAP[major]
103
- if (fullVersion) {
104
- fallbackMap[major] = [fullVersion]
105
- }
106
- }
107
-
108
- return fallbackMap
109
- }
110
- }
111
-
112
- /**
113
- * Clear the version cache (useful for testing)
114
- */
115
- export function clearVersionCache(): void {
116
- cachedVersions = null
117
- cacheExpiry = 0
118
- }
10
+ import { typedbBinaryManager } from './binary-manager'
11
+ import { Engine } from '../../types'
12
+
13
+ const hostdbReleases = createHostdbReleases({
14
+ engine: Engine.TypeDB,
15
+ displayName: 'TypeDB',
16
+ versionMap: TYPEDB_VERSION_MAP,
17
+ supportedMajorVersions: SUPPORTED_MAJOR_VERSIONS,
18
+ groupingStrategy: 'single-digit',
19
+ listInstalled: () => typedbBinaryManager.listInstalled(),
20
+ })
21
+
22
+ export const fetchAvailableVersions = hostdbReleases.fetchAvailableVersions
23
+ export const getLatestVersion = hostdbReleases.getLatestVersion
@@ -2,7 +2,7 @@
2
2
  * TypeDB version mapping
3
3
  *
4
4
  * Maps short version aliases to full versions from hostdb releases.
5
- * MUST stay in sync with hostdb releases.json
5
+ * MUST stay in sync with hostdb databases.json
6
6
  */
7
7
 
8
8
  import { logDebug } from '../../core/error-handler'
@@ -37,7 +37,7 @@ export function getHostdbPlatform(
37
37
  /**
38
38
  * Build the download URL for Valkey binaries from hostdb
39
39
  *
40
- * Format: https://github.com/robertjbass/hostdb/releases/download/valkey-{version}/valkey-{version}-{platform}-{arch}.{ext}
40
+ * Format: https://registry.layerbase.host/valkey-{version}/valkey-{version}-{platform}-{arch}.{ext}
41
41
  *
42
42
  * @param version - Valkey version (e.g., '8', '8.0.6')
43
43
  * @param platform - Platform identifier (e.g., 'darwin', 'linux', 'win32')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spindb",
3
- "version": "0.34.5",
3
+ "version": "0.35.2",
4
4
  "author": "Bob Bass <bob@bbass.co>",
5
5
  "license": "PolyForm-Noncommercial-1.0.0",
6
6
  "description": "Zero-config Docker-free local database containers. Create, backup, and clone a variety of popular databases.",
@@ -35,6 +35,7 @@
35
35
  "spindb",
36
36
  "postgres",
37
37
  "postgresql",
38
+ "postgresql-documentdb",
38
39
  "mysql",
39
40
  "mariadb",
40
41
  "database",
@@ -55,6 +56,8 @@
55
56
  "questdb",
56
57
  "typedb",
57
58
  "influxdb",
59
+ "layerbase",
60
+ "docker-free",
58
61
  "tui",
59
62
  "cli",
60
63
  "package manager"