vaultkit 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ef641bfa848899716802a548282d99ceb00882f2ebace64e73cad6a465e3f39
4
- data.tar.gz: b45579cba40972b3500af392d872c226eec3499fa884179fa87dbeb3a0b7711e
3
+ metadata.gz: e4b12d7696d6e2ec91bdf7843bd8648a1c9f0fdce6c59a6c4cbc902b3e4739c8
4
+ data.tar.gz: 7ae893269eb4075c797294585af9f28ad5da121f892b11e7d2e12ea8f625e956
5
5
  SHA512:
6
- metadata.gz: 3ac9dd5b9b100dcdbf1a141f25bf1e686efcf9376dd5182aa3827c0b1457b571e65ba8f5fabe6a17a8473d3e4909306d74ef6003421ddf07f5f77e692848cc7d
7
- data.tar.gz: f98f55a48d58315877e824663a8c9d4499542f661b838dadf2b5dd534ec66583b43dc4db25d75a55be187aabaa7ae92b2f7abc87634da61ba143f44bfb85d23b
6
+ metadata.gz: 48fc209dc487ee6649012b5d59da82946b37339cf4d3e1875d34c98146e07c79b93147ea510b98674736b6baf81c422a317f699c287103d0fe354e9191aadfb0
7
+ data.tar.gz: 62970b31c4cc95ab323e8f2868e41c4214905e680b427a9fe2475621d3e705b0d690c1ad44c113abd5d0b4186398322485b617cca332376c66abdeaacf0d4f6d
@@ -31,6 +31,11 @@ module Vkit
31
31
  Commands::LogoutCommand.new.call
32
32
  end
33
33
 
34
+ desc "reset", "Clear all stored credentials and configuration"
35
+ def reset
36
+ Commands::ResetCommand.new.call
37
+ end
38
+
34
39
  # REQUEST
35
40
  desc "request", "Send an inline JSON AQL request (use --aql or pipe via STDIN)"
36
41
  option :aql, type: :string, desc: "AQL JSON payload (inline)"
@@ -71,6 +76,20 @@ module Vkit
71
76
  )
72
77
  end
73
78
 
79
+ desc "approvals:watch", "Watch pending approval requests"
80
+ option :interval, type: :numeric, default: 3, desc: "Polling interval in seconds"
81
+ option :format, type: :string, default: "table", enum: %w[table json], desc: "Output format (table for humans, json for automations)"
82
+ option :pretty, type: :boolean, default: false, desc: "Pretty-print JSON output"
83
+ option :since, type: :string, desc: "Only show approvals created after this time (ISO8601 or 10m, 2h)"
84
+ define_method("approvals:watch") do
85
+ Commands::ApprovalWatchCommand.new.call(
86
+ interval: options[:interval],
87
+ format: options[:format],
88
+ pretty: options[:pretty],
89
+ since: options[:since]
90
+ )
91
+ end
92
+
74
93
  # FETCH
75
94
  desc "fetch --grant ID", "Fetch data from Funl using a valid grant"
76
95
  option :grant, type: :string, required: true
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "time"
5
+
6
+ module Vkit
7
+ module CLI
8
+ module Commands
9
+ class ApprovalWatchCommand < BaseCommand
10
+ DEFAULT_INTERVAL = 3
11
+
12
+ def call(interval: DEFAULT_INTERVAL, format: "table", pretty: false, since: nil)
13
+ with_auth do
14
+ user = credential_store.user
15
+ org = user["organization_slug"]
16
+
17
+ since_time = parse_since(since)
18
+ seen = {}
19
+
20
+ if format == "table"
21
+ puts "⏳ Watching approval queue (Ctrl+C to stop)…"
22
+ puts "Since: #{since_time.iso8601}" if since_time
23
+ puts
24
+ end
25
+
26
+ loop do
27
+ approvals =
28
+ authenticated_client.get(
29
+ "/api/v1/orgs/#{org}/approvals",
30
+ params: build_query(since_time)
31
+ )
32
+
33
+ approvals.each do |approval|
34
+ next if seen[approval["id"]]
35
+
36
+ emit(approval, format, pretty)
37
+ seen[approval["id"]] = true
38
+ end
39
+
40
+ sleep interval
41
+ end
42
+ end
43
+ rescue Interrupt
44
+ puts "\n👋 Watch stopped." if format == "table"
45
+ end
46
+
47
+ private
48
+
49
+ def build_query(since_time)
50
+ {}.tap do |q|
51
+ q[:state] = "pending"
52
+ q[:since] = since_time.iso8601 if since_time
53
+ end
54
+ end
55
+
56
+ def parse_since(value)
57
+ return nil if value.nil?
58
+
59
+ now = Time.now.utc
60
+
61
+ case value
62
+ when /\A(\d+)m\z/
63
+ now - Regexp.last_match(1).to_i * 60
64
+ when /\A(\d+)h\z/
65
+ now - Regexp.last_match(1).to_i * 60 * 60
66
+ when /\A(\d+)d\z/
67
+ now - Regexp.last_match(1).to_i * 60 * 60 * 24
68
+ else
69
+ Time.iso8601(value)
70
+ end
71
+ rescue ArgumentError
72
+ raise "Invalid --since value (use ISO8601 or 10m, 2h, 1d)"
73
+ end
74
+
75
+ def emit(approval, format, pretty)
76
+ case format
77
+ when "json"
78
+ print_json(normalize(approval), pretty: pretty)
79
+ when "table"
80
+ render_human(approval)
81
+ else
82
+ raise "Unknown format: #{format}"
83
+ end
84
+ end
85
+
86
+ def print_json(obj, pretty:)
87
+ if pretty
88
+ puts JSON.pretty_generate(obj)
89
+ else
90
+ puts JSON.generate(obj)
91
+ end
92
+ end
93
+
94
+ def normalize(a)
95
+ {
96
+ type: "approval.pending",
97
+ id: a["id"],
98
+ dataset: a["dataset"],
99
+ fields: a["fields"],
100
+ requester: a["requester"],
101
+ approver_role: a["approver_role"],
102
+ created_at: a["created_at"]
103
+ }
104
+ end
105
+
106
+ def render_human(a)
107
+ puts "🔔 NEW APPROVAL"
108
+ puts "────────────────────────────"
109
+ puts "ID: #{a["id"]}"
110
+ puts "Dataset: #{a["dataset"]}"
111
+ puts "Fields: #{Array(a["fields"]).join(", ")}"
112
+ puts "Requester: #{a["requester"]}"
113
+ puts "Role Req: #{a["approver_role"] || "any"}"
114
+ puts "Created: #{format_time(a["created_at"])}"
115
+ puts
116
+ puts "▶ Approve: vkit approval approve #{a["id"]}"
117
+ puts "▶ Deny: vkit approval deny #{a["id"]} --reason \"…\""
118
+ puts
119
+ end
120
+
121
+ def format_time(value)
122
+ Time.parse(value).getlocal.strftime("%Y-%m-%d %H:%M:%S")
123
+ rescue
124
+ value
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,20 @@
1
+ module Vkit
2
+ module CLI
3
+ module Commands
4
+ class ResetCommand < BaseCommand
5
+ def call
6
+ print "⚠️ This will clear all stored credentials. Continue? (y/N): "
7
+ response = $stdin.gets.chomp
8
+
9
+ unless response.downcase == 'y'
10
+ puts "Cancelled"
11
+ return
12
+ end
13
+
14
+ credential_store.clear!
15
+ puts "🧹 All credentials cleared"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/vkit/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vkit
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vaultkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nnamdi Ogundu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-22 00:00:00.000000000 Z
11
+ date: 2026-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -44,6 +44,7 @@ files:
44
44
  - lib/vkit/cli/commands/agent_tokens_list_command.rb
45
45
  - lib/vkit/cli/commands/agent_tokens_revoke_command.rb
46
46
  - lib/vkit/cli/commands/approval_command.rb
47
+ - lib/vkit/cli/commands/approval_watch_command.rb
47
48
  - lib/vkit/cli/commands/base_command.rb
48
49
  - lib/vkit/cli/commands/datasource_command.rb
49
50
  - lib/vkit/cli/commands/fetch_command.rb
@@ -54,6 +55,7 @@ files:
54
55
  - lib/vkit/cli/commands/policy_validate_command.rb
55
56
  - lib/vkit/cli/commands/request_command.rb
56
57
  - lib/vkit/cli/commands/requests_list_command.rb
58
+ - lib/vkit/cli/commands/reset_command.rb
57
59
  - lib/vkit/cli/commands/scan_command.rb
58
60
  - lib/vkit/cli/commands/whoami_command.rb
59
61
  - lib/vkit/cli/errors.rb