vectra-client 1.1.3 → 1.1.4
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 +4 -4
- data/CHANGELOG.md +7 -3
- data/docs/api/cheatsheet.md +13 -0
- data/docs/api/methods.md +39 -0
- data/lib/vectra/client.rb +43 -1
- data/lib/vectra/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2ed5842cd4c611fd0c140abc8925a2d13577c4f2094dbc71c7b2772aceda9e4
|
|
4
|
+
data.tar.gz: da3005805b97d5b36c632d3e2c34ad9a3966eb65b09ce2f5f84911858c2d34d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb3324f260afb42c5e03356f8d09c902571fcaddc39969541c918523c4ebadbdb8dadf35764d9d04cce2b308ee4aa18d9f7c3266690a1a728ceeecb9908a3622
|
|
7
|
+
data.tar.gz: adca9a174757547d1306dbaa727069fa1954a8dc40b101c1cb378bfb3663c94ad7ec0a35082ea578ef4dd4a7ab53477bdfde6dd258623c83e161eb8c6cff2b42
|
data/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v1.1.4](https://github.com/stokry/vectra/tree/v1.1.4) (2026-01-20)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/stokry/vectra/compare/v1.1.3...v1.1.4)
|
|
6
|
+
|
|
7
|
+
- Add `Client#valid?` – non-raising validation (returns true/false)
|
|
8
|
+
- Add `Client#for_tenant` – multi-tenant block helper for namespace isolation
|
|
9
|
+
|
|
3
10
|
## [v1.1.3](https://github.com/stokry/vectra/tree/v1.1.3) (2026-01-20)
|
|
4
11
|
|
|
5
12
|
[Full Changelog](https://github.com/stokry/vectra/compare/v1.1.2...v1.1.3)
|
|
6
13
|
|
|
7
|
-
- Add `Client#validate!` for configuration/capability checks
|
|
8
|
-
- Add `Client#with_defaults` block helper for temporary default index/namespace
|
|
9
|
-
|
|
10
14
|
## [v1.1.2](https://github.com/stokry/vectra/tree/v1.1.2) (2026-01-19)
|
|
11
15
|
|
|
12
16
|
[Full Changelog](https://github.com/stokry/vectra/compare/v1.1.1...v1.1.2)
|
data/docs/api/cheatsheet.md
CHANGED
|
@@ -66,6 +66,19 @@ end
|
|
|
66
66
|
client.validate!
|
|
67
67
|
client.validate!(require_default_index: true)
|
|
68
68
|
client.validate!(features: [:text_search])
|
|
69
|
+
|
|
70
|
+
# Non-raising: returns true/false
|
|
71
|
+
client.valid?
|
|
72
|
+
client.valid?(require_default_index: true)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Multi-tenant (for_tenant)
|
|
76
|
+
|
|
77
|
+
```ruby
|
|
78
|
+
client.for_tenant("acme", namespace_prefix: "tenant_") do |c|
|
|
79
|
+
c.upsert(vectors: [...])
|
|
80
|
+
c.query(vector: query_embedding, top_k: 10)
|
|
81
|
+
end
|
|
69
82
|
```
|
|
70
83
|
|
|
71
84
|
### Upsert
|
data/docs/api/methods.md
CHANGED
|
@@ -475,6 +475,45 @@ end
|
|
|
475
475
|
|
|
476
476
|
---
|
|
477
477
|
|
|
478
|
+
### `client.valid?(require_default_index: false, require_default_namespace: false, features: [])`
|
|
479
|
+
|
|
480
|
+
Non-raising validation. Returns `true` if the client passes `validate!`, `false` otherwise. Accepts the same options as `validate!`.
|
|
481
|
+
|
|
482
|
+
**Returns:** `Boolean`
|
|
483
|
+
|
|
484
|
+
**Example:**
|
|
485
|
+
```ruby
|
|
486
|
+
next unless client.valid?
|
|
487
|
+
client.upsert(vectors: [...])
|
|
488
|
+
|
|
489
|
+
# With same options as validate!
|
|
490
|
+
client.valid?(require_default_index: true)
|
|
491
|
+
client.valid?(features: [:text_search])
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
### `client.for_tenant(tenant_id, namespace_prefix: "tenant_") { ... }`
|
|
497
|
+
|
|
498
|
+
Multi-tenant block helper. Temporarily sets the default namespace to `"#{namespace_prefix}#{tenant_id}"`, yields the client, then restores the previous namespace. `tenant_id` can be a string, symbol, or anything responding to `to_s`.
|
|
499
|
+
|
|
500
|
+
**Parameters:**
|
|
501
|
+
- `tenant_id` (String, Symbol, #to_s) - Tenant identifier
|
|
502
|
+
- `namespace_prefix` (String) - Prefix for namespace (default: `"tenant_"`)
|
|
503
|
+
|
|
504
|
+
**Returns:** Block result
|
|
505
|
+
|
|
506
|
+
**Example:**
|
|
507
|
+
```ruby
|
|
508
|
+
client.for_tenant("acme", namespace_prefix: "tenant_") do |c|
|
|
509
|
+
c.upsert(vectors: [...])
|
|
510
|
+
c.query(vector: embedding, top_k: 10)
|
|
511
|
+
end
|
|
512
|
+
# All operations use namespace "tenant_acme"; previous default restored after block.
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
478
517
|
### `client.health_check`
|
|
479
518
|
|
|
480
519
|
Detailed health check with provider-specific information.
|
data/lib/vectra/client.rb
CHANGED
|
@@ -661,6 +661,30 @@ module Vectra
|
|
|
661
661
|
self
|
|
662
662
|
end
|
|
663
663
|
|
|
664
|
+
# Non-raising validation. Returns true if client passes validate!, false otherwise.
|
|
665
|
+
#
|
|
666
|
+
# Accepts the same options as validate!.
|
|
667
|
+
#
|
|
668
|
+
# @param require_default_index [Boolean] require default index to be set
|
|
669
|
+
# @param require_default_namespace [Boolean] require default namespace to be set
|
|
670
|
+
# @param features [Array<Symbol>, Symbol] provider features required, e.g. :text_search
|
|
671
|
+
# @return [Boolean]
|
|
672
|
+
#
|
|
673
|
+
# @example
|
|
674
|
+
# next unless client.valid?
|
|
675
|
+
# client.upsert(vectors: [...])
|
|
676
|
+
#
|
|
677
|
+
def valid?(require_default_index: false, require_default_namespace: false, features: [])
|
|
678
|
+
validate!(
|
|
679
|
+
require_default_index: require_default_index,
|
|
680
|
+
require_default_namespace: require_default_namespace,
|
|
681
|
+
features: features
|
|
682
|
+
)
|
|
683
|
+
true
|
|
684
|
+
rescue ConfigurationError
|
|
685
|
+
false
|
|
686
|
+
end
|
|
687
|
+
|
|
664
688
|
# Chainable query builder
|
|
665
689
|
#
|
|
666
690
|
# @api public
|
|
@@ -1016,7 +1040,25 @@ module Vectra
|
|
|
1016
1040
|
@default_namespace = previous_namespace
|
|
1017
1041
|
end
|
|
1018
1042
|
|
|
1019
|
-
|
|
1043
|
+
# Multi-tenant block helper: temporarily sets default namespace to +"#{namespace_prefix}#{tenant_id}"+.
|
|
1044
|
+
#
|
|
1045
|
+
# @param tenant_id [String, Symbol, #to_s] tenant identifier
|
|
1046
|
+
# @param namespace_prefix [String] prefix for namespace (default: "tenant_")
|
|
1047
|
+
# @yield [Client] yields self with overridden namespace
|
|
1048
|
+
# @return [Object] block result
|
|
1049
|
+
#
|
|
1050
|
+
# @example
|
|
1051
|
+
# client.for_tenant("acme", namespace_prefix: "tenant_") do |c|
|
|
1052
|
+
# c.upsert(vectors: [...])
|
|
1053
|
+
# c.query(vector: emb, top_k: 10)
|
|
1054
|
+
# end
|
|
1055
|
+
#
|
|
1056
|
+
def for_tenant(tenant_id, namespace_prefix: "tenant_")
|
|
1057
|
+
ns = "#{namespace_prefix}#{tenant_id}"
|
|
1058
|
+
with_namespace(ns) { yield self }
|
|
1059
|
+
end
|
|
1060
|
+
|
|
1061
|
+
public :with_index, :with_namespace, :with_index_and_namespace, :with_defaults, :with_timeout, :for_tenant
|
|
1020
1062
|
end
|
|
1021
1063
|
# rubocop:enable Metrics/ClassLength
|
|
1022
1064
|
end
|
data/lib/vectra/version.rb
CHANGED