axiodb 20.3.2 → 20.3.3
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/package.json +1 -1
- package/.graphifyignore +0 -12
- package/cli/VERSION +0 -1
- package/cli/cmd/auth_management.go +0 -68
- package/cli/cmd/collection.go +0 -169
- package/cli/cmd/connect.go +0 -597
- package/cli/cmd/db.go +0 -171
- package/cli/cmd/db_export.go +0 -66
- package/cli/cmd/db_import.go +0 -84
- package/cli/cmd/document.go +0 -409
- package/cli/cmd/health.go +0 -19
- package/cli/cmd/index.go +0 -101
- package/cli/cmd/ping.go +0 -36
- package/cli/cmd/root.go +0 -38
- package/cli/cmd/transaction.go +0 -191
- package/cli/cmd/version.go +0 -27
- package/cli/go.mod +0 -15
- package/cli/go.sum +0 -20
- package/cli/internal/config/config.go +0 -120
- package/cli/main.go +0 -7
- package/cli/pkg/commands/collection.go +0 -68
- package/cli/pkg/commands/db.go +0 -62
- package/cli/pkg/commands/document.go +0 -203
- package/cli/pkg/commands/health.go +0 -18
- package/cli/pkg/commands/index.go +0 -51
- package/cli/pkg/commands/transaction.go +0 -84
- package/cli/pkg/httpclient/client.go +0 -236
- package/cli/pkg/protocol/auth.go +0 -46
- package/cli/pkg/protocol/client.go +0 -174
- package/cli/pkg/protocol/message.go +0 -75
- package/lib/engine/cli/worker_process.d.ts +0 -6
- package/lib/engine/cli/worker_process.js +0 -63
- package/lib/engine/cli/worker_process.js.map +0 -1
- package/opencode.json +0 -9
package/cli/cmd/db.go
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
package cmd
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"encoding/json"
|
|
5
|
-
"fmt"
|
|
6
|
-
"os"
|
|
7
|
-
|
|
8
|
-
"github.com/nexoral/axiodb-cli/internal/config"
|
|
9
|
-
"github.com/nexoral/axiodb-cli/pkg/commands"
|
|
10
|
-
"github.com/nexoral/axiodb-cli/pkg/protocol"
|
|
11
|
-
"github.com/spf13/cobra"
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
var dbCmd = &cobra.Command{
|
|
15
|
-
Use: "db",
|
|
16
|
-
Short: "Database operations",
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var dbCreateCmd = &cobra.Command{
|
|
20
|
-
Use: "create <name>",
|
|
21
|
-
Short: "Create a database",
|
|
22
|
-
Args: cobra.ExactArgs(1),
|
|
23
|
-
RunE: func(cmd *cobra.Command, args []string) error {
|
|
24
|
-
cfg, err := config.FromFlags(cmd)
|
|
25
|
-
if err != nil {
|
|
26
|
-
return err
|
|
27
|
-
}
|
|
28
|
-
client, err := cfg.ConnectAndAuth()
|
|
29
|
-
if err != nil {
|
|
30
|
-
return err
|
|
31
|
-
}
|
|
32
|
-
defer client.Disconnect()
|
|
33
|
-
|
|
34
|
-
resp, err := commands.CreateDB(client, args[0])
|
|
35
|
-
if err != nil {
|
|
36
|
-
return err
|
|
37
|
-
}
|
|
38
|
-
return printOutput(cfg.Output, resp)
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var dbDeleteCmd = &cobra.Command{
|
|
43
|
-
Use: "delete <name>",
|
|
44
|
-
Short: "Delete a database",
|
|
45
|
-
Args: cobra.ExactArgs(1),
|
|
46
|
-
RunE: func(cmd *cobra.Command, args []string) error {
|
|
47
|
-
cfg, err := config.FromFlags(cmd)
|
|
48
|
-
if err != nil {
|
|
49
|
-
return err
|
|
50
|
-
}
|
|
51
|
-
client, err := cfg.ConnectAndAuth()
|
|
52
|
-
if err != nil {
|
|
53
|
-
return err
|
|
54
|
-
}
|
|
55
|
-
defer client.Disconnect()
|
|
56
|
-
|
|
57
|
-
resp, err := commands.DeleteDB(client, args[0])
|
|
58
|
-
if err != nil {
|
|
59
|
-
return err
|
|
60
|
-
}
|
|
61
|
-
return printOutput(cfg.Output, resp)
|
|
62
|
-
},
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var dbExistsCmd = &cobra.Command{
|
|
66
|
-
Use: "exists <name>",
|
|
67
|
-
Short: "Check if a database exists",
|
|
68
|
-
Args: cobra.ExactArgs(1),
|
|
69
|
-
RunE: func(cmd *cobra.Command, args []string) error {
|
|
70
|
-
cfg, err := config.FromFlags(cmd)
|
|
71
|
-
if err != nil {
|
|
72
|
-
return err
|
|
73
|
-
}
|
|
74
|
-
client, err := cfg.ConnectAndAuth()
|
|
75
|
-
if err != nil {
|
|
76
|
-
return err
|
|
77
|
-
}
|
|
78
|
-
defer client.Disconnect()
|
|
79
|
-
|
|
80
|
-
exists, err := commands.DBExists(client, args[0])
|
|
81
|
-
if err != nil {
|
|
82
|
-
return err
|
|
83
|
-
}
|
|
84
|
-
fmt.Printf("Database '%s' exists: %v\n", args[0], exists)
|
|
85
|
-
return nil
|
|
86
|
-
},
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
var dbInfoCmd = &cobra.Command{
|
|
90
|
-
Use: "info",
|
|
91
|
-
Short: "Get instance information",
|
|
92
|
-
RunE: func(cmd *cobra.Command, args []string) error {
|
|
93
|
-
cfg, err := config.FromFlags(cmd)
|
|
94
|
-
if err != nil {
|
|
95
|
-
return err
|
|
96
|
-
}
|
|
97
|
-
client, err := cfg.ConnectAndAuth()
|
|
98
|
-
if err != nil {
|
|
99
|
-
return err
|
|
100
|
-
}
|
|
101
|
-
defer client.Disconnect()
|
|
102
|
-
|
|
103
|
-
resp, err := commands.GetInstanceInfo(client)
|
|
104
|
-
if err != nil {
|
|
105
|
-
return err
|
|
106
|
-
}
|
|
107
|
-
return printOutput(cfg.Output, resp)
|
|
108
|
-
},
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
var dbListCmd = &cobra.Command{
|
|
112
|
-
Use: "list",
|
|
113
|
-
Short: "List all databases",
|
|
114
|
-
RunE: func(cmd *cobra.Command, args []string) error {
|
|
115
|
-
cfg, err := config.FromFlags(cmd)
|
|
116
|
-
if err != nil {
|
|
117
|
-
return err
|
|
118
|
-
}
|
|
119
|
-
client, err := cfg.ConnectAndAuth()
|
|
120
|
-
if err != nil {
|
|
121
|
-
return err
|
|
122
|
-
}
|
|
123
|
-
defer client.Disconnect()
|
|
124
|
-
|
|
125
|
-
resp, err := commands.GetInstanceInfo(client)
|
|
126
|
-
if err != nil {
|
|
127
|
-
return err
|
|
128
|
-
}
|
|
129
|
-
return printOutput(cfg.Output, resp)
|
|
130
|
-
},
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
func init() {
|
|
134
|
-
dbCmd.AddCommand(dbCreateCmd)
|
|
135
|
-
dbCmd.AddCommand(dbDeleteCmd)
|
|
136
|
-
dbCmd.AddCommand(dbExistsCmd)
|
|
137
|
-
dbCmd.AddCommand(dbInfoCmd)
|
|
138
|
-
dbCmd.AddCommand(dbListCmd)
|
|
139
|
-
rootCmd.AddCommand(dbCmd)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
func printOutput(format string, data interface{}) error {
|
|
143
|
-
if format == "json" {
|
|
144
|
-
encoder := json.NewEncoder(os.Stdout)
|
|
145
|
-
encoder.SetIndent("", " ")
|
|
146
|
-
return encoder.Encode(data)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
jsonBytes, err := json.MarshalIndent(data, "", " ")
|
|
150
|
-
if err != nil {
|
|
151
|
-
return err
|
|
152
|
-
}
|
|
153
|
-
fmt.Println(string(jsonBytes))
|
|
154
|
-
return nil
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
func createDB(client *protocol.Client, name string) (*protocol.Response, error) {
|
|
158
|
-
return commands.CreateDB(client, name)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
func deleteDB(client *protocol.Client, name string) (*protocol.Response, error) {
|
|
162
|
-
return commands.DeleteDB(client, name)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
func dbExists(client *protocol.Client, name string) (bool, error) {
|
|
166
|
-
return commands.DBExists(client, name)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
func getInstanceInfo(client *protocol.Client) (*protocol.Response, error) {
|
|
170
|
-
return commands.GetInstanceInfo(client)
|
|
171
|
-
}
|
package/cli/cmd/db_export.go
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
package cmd
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"fmt"
|
|
5
|
-
"os"
|
|
6
|
-
|
|
7
|
-
"github.com/nexoral/axiodb-cli/internal/config"
|
|
8
|
-
"github.com/spf13/cobra"
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
var exportCmd = &cobra.Command{
|
|
12
|
-
Use: "export <dbname>",
|
|
13
|
-
Short: "Export a database to a .tar.gz file via HTTP",
|
|
14
|
-
Long: "Export an AxioDB database to a .tar.gz archive. Uses the HTTP API (port 27018), not TCP.",
|
|
15
|
-
Args: cobra.ExactArgs(1),
|
|
16
|
-
RunE: func(cmd *cobra.Command, args []string) error {
|
|
17
|
-
dbName := args[0]
|
|
18
|
-
cfg, err := config.FromFlags(cmd)
|
|
19
|
-
if err != nil {
|
|
20
|
-
return err
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if cfg.Username == "" || cfg.Password == "" {
|
|
24
|
-
return fmt.Errorf("username and password required for HTTP auth (-u, -p)")
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
client := cfg.NewHTTPClient()
|
|
28
|
-
|
|
29
|
-
fmt.Fprintf(os.Stderr, "Logging in to %s:%d...\n", cfg.HTTPHost, cfg.HTTPPort)
|
|
30
|
-
if err := client.Login(cfg.Username, cfg.Password); err != nil {
|
|
31
|
-
return err
|
|
32
|
-
}
|
|
33
|
-
defer client.Logout()
|
|
34
|
-
|
|
35
|
-
fmt.Fprintf(os.Stderr, "Exporting %s...\n", dbName)
|
|
36
|
-
filename, size, err := client.Export(dbName)
|
|
37
|
-
if err != nil {
|
|
38
|
-
return err
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
fmt.Fprintf(os.Stderr, "Exported %s (%s)\n", filename, formatBytes(size))
|
|
42
|
-
return nil
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
func formatBytes(bytes int64) string {
|
|
47
|
-
const (
|
|
48
|
-
KB = 1024
|
|
49
|
-
MB = 1024 * KB
|
|
50
|
-
GB = 1024 * MB
|
|
51
|
-
)
|
|
52
|
-
switch {
|
|
53
|
-
case bytes >= GB:
|
|
54
|
-
return fmt.Sprintf("%.1f GB", float64(bytes)/float64(GB))
|
|
55
|
-
case bytes >= MB:
|
|
56
|
-
return fmt.Sprintf("%.1f MB", float64(bytes)/float64(MB))
|
|
57
|
-
case bytes >= KB:
|
|
58
|
-
return fmt.Sprintf("%.1f KB", float64(bytes)/float64(KB))
|
|
59
|
-
default:
|
|
60
|
-
return fmt.Sprintf("%d B", bytes)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
func init() {
|
|
65
|
-
rootCmd.AddCommand(exportCmd)
|
|
66
|
-
}
|
package/cli/cmd/db_import.go
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
package cmd
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"fmt"
|
|
5
|
-
"os"
|
|
6
|
-
"path/filepath"
|
|
7
|
-
"strings"
|
|
8
|
-
|
|
9
|
-
"github.com/nexoral/axiodb-cli/internal/config"
|
|
10
|
-
"github.com/spf13/cobra"
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
var importCmd = &cobra.Command{
|
|
14
|
-
Use: "import <file>",
|
|
15
|
-
Short: "Import a database from a .tar.gz file via HTTP",
|
|
16
|
-
Long: "Import an AxioDB database from a .tar.gz archive. Uses the HTTP API (port 27018), not TCP.",
|
|
17
|
-
Args: cobra.ExactArgs(1),
|
|
18
|
-
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
19
|
-
dir := "."
|
|
20
|
-
prefix := toComplete
|
|
21
|
-
|
|
22
|
-
if idx := strings.LastIndex(toComplete, "/"); idx >= 0 {
|
|
23
|
-
dir = toComplete[:idx+1]
|
|
24
|
-
prefix = toComplete[idx+1:]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
entries, err := os.ReadDir(dir)
|
|
28
|
-
if err != nil {
|
|
29
|
-
return nil, cobra.ShellCompDirectiveDefault
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var completions []string
|
|
33
|
-
for _, entry := range entries {
|
|
34
|
-
if entry.IsDir() {
|
|
35
|
-
continue
|
|
36
|
-
}
|
|
37
|
-
name := entry.Name()
|
|
38
|
-
if strings.HasPrefix(name, prefix) && strings.HasSuffix(name, ".tar.gz") {
|
|
39
|
-
completions = append(completions, filepath.Join(dir, name))
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return completions, cobra.ShellCompDirectiveNoFileComp
|
|
43
|
-
},
|
|
44
|
-
RunE: func(cmd *cobra.Command, args []string) error {
|
|
45
|
-
filePath := args[0]
|
|
46
|
-
cfg, err := config.FromFlags(cmd)
|
|
47
|
-
if err != nil {
|
|
48
|
-
return err
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if cfg.Username == "" || cfg.Password == "" {
|
|
52
|
-
return fmt.Errorf("username and password required for HTTP auth (-u, -p)")
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
info, err := os.Stat(filePath)
|
|
56
|
-
if err != nil {
|
|
57
|
-
return fmt.Errorf("file not found: %s", filePath)
|
|
58
|
-
}
|
|
59
|
-
if info.IsDir() {
|
|
60
|
-
return fmt.Errorf("not a file: %s", filePath)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
client := cfg.NewHTTPClient()
|
|
64
|
-
|
|
65
|
-
fmt.Fprintf(os.Stderr, "Logging in to %s:%d...\n", cfg.HTTPHost, cfg.HTTPPort)
|
|
66
|
-
if err := client.Login(cfg.Username, cfg.Password); err != nil {
|
|
67
|
-
return err
|
|
68
|
-
}
|
|
69
|
-
defer client.Logout()
|
|
70
|
-
|
|
71
|
-
fmt.Fprintf(os.Stderr, "Importing %s...\n", filepath.Base(filePath))
|
|
72
|
-
dbName, err := client.Import(filePath)
|
|
73
|
-
if err != nil {
|
|
74
|
-
return err
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
fmt.Fprintf(os.Stderr, "Imported database: %s\n", dbName)
|
|
78
|
-
return nil
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
func init() {
|
|
83
|
-
rootCmd.AddCommand(importCmd)
|
|
84
|
-
}
|