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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83a312bb14b8f556d743e0072548a33ec0ac79c9d64768c78b18af3bc7ac6c6b
4
- data.tar.gz: 0f0e859dd346e86f095a882e4cb7d47fd1ecf05aa968730b2b3e0d2ff7fa253b
3
+ metadata.gz: c2ed5842cd4c611fd0c140abc8925a2d13577c4f2094dbc71c7b2772aceda9e4
4
+ data.tar.gz: da3005805b97d5b36c632d3e2c34ad9a3966eb65b09ce2f5f84911858c2d34d5
5
5
  SHA512:
6
- metadata.gz: ccbc0520ce83f7d2f039a50c0a4b16a9fb59ce21956eb00d5f28270bf61e3ae6c81ab133b02b3ffd1662d29864f5b0ae9c04f60b8e61715f8cbb513b71d48c72
7
- data.tar.gz: 38a9b1bbfc4db14005b88d1f29957806f888dc80886c147925fe9dec1643ca67e992aae71258108130ba33b317b999658df5a7756fffe92f0f91bb39b3ba88d1
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)
@@ -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
- public :with_index, :with_namespace, :with_index_and_namespace, :with_defaults, :with_timeout
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vectra
4
- VERSION = "1.1.3"
4
+ VERSION = "1.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vectra-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mijo Kristo