backlex 0.0.1 → 0.1.0

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: 01f91fb97df5e3be829a139e6f6b8ca5ed6db3ff6964e23fbe98993f88aaca36
4
- data.tar.gz: 9846419c9ad1c7b62322a311538a2c88e0dbd2aa579f418c865602d07c268fcf
3
+ metadata.gz: bba9b8d247e2372b316c0b7acc4a2301a6be7dc905640b0711d7ca6d11720a32
4
+ data.tar.gz: 64e10d54b9861177832c9eee721aec82350aa595a0b7aaaa881cdc619f3ddfe4
5
5
  SHA512:
6
- metadata.gz: 9253fd5739603b9ae274ef5d80a401d7b2e18a88cffe9aaeec8fd25407be4a128cac8ae4d81fc73bb76a73ae58a19d0106300305bb271cf3df779cebc0654886
7
- data.tar.gz: 56c161ee05698e5c476bb8bd1c17975baf6bd4d937e6bf1793e61241030707909c55cf0fb7cfd147a3dbf2fae4a99a5432f31a2b5d6fe2f1e4bcb94a0d50eecc
6
+ metadata.gz: 671cc7adec723956b25e58ac83c5b50042f96b7a280e7531f8534b472ec62d69fd859c4cee3c07c0333541457ed80a725d04b68526d164810f66f6058286bdae
7
+ data.tar.gz: 4364e6edbf173987962ceb830df6e8f3c5207c7346ea9963aa06d338056707fc4213f8bf912ebada7cf871f3fc8bb07ac4fe61dc65bb5d2af16351aaa08b6718
data/README.md CHANGED
@@ -9,7 +9,7 @@ Part of backlex's multi-language SDK effort; follows the **hybrid** model:
9
9
  hand-written ergonomic layer here, optional OpenAPI-generated models underneath.
10
10
 
11
11
  ```bash
12
- gem install backlex # not yet published
12
+ gem install backlex
13
13
  ```
14
14
 
15
15
  ## Quickstart
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "net/http"
4
+ require "securerandom"
4
5
  require "uri"
5
6
  require "json"
6
7
 
@@ -12,12 +13,25 @@ module Backlex
12
13
  attr_reader :workspace
13
14
  attr_accessor :app_token
14
15
 
15
- def initialize(url, api_key: nil, workspace: nil, token: nil, tenant: nil)
16
+ # Act inside a specific organization (slug or id) from here on, so `$org.id`
17
+ # in permission rules resolves without threading it through every call.
18
+ attr_accessor :org
19
+
20
+ def initialize(url, api_key: nil, workspace: nil, token: nil, tenant: nil, org: nil, tracing: true)
16
21
  @url = url.chomp("/")
17
22
  @api_key = api_key
18
23
  @workspace = workspace
19
24
  @app_token = token
20
25
  @tenant = tenant
26
+ @org = org
27
+ @tracing = tracing
28
+ end
29
+
30
+ # A W3C traceparent: 00-<32-hex trace id>-<16-hex span id>-01. Mirrors
31
+ # packages/client/src/trace.ts, which is what the API parses. Fresh per
32
+ # request — a span id reused across calls collapses them into one span.
33
+ def self.make_traceparent
34
+ "00-#{SecureRandom.hex(16)}-#{SecureRandom.hex(8)}-01"
21
35
  end
22
36
 
23
37
  # CRUD handle for a collection.
@@ -80,6 +94,8 @@ module Backlex
80
94
  res.body
81
95
  end
82
96
 
97
+ # The one chokepoint every request path goes through (data, storage,
98
+ # realtime) — a header added here reaches every call.
83
99
  def auth_header(req)
84
100
  if @api_key
85
101
  req["Authorization"] = "Bearer #{@api_key}"
@@ -87,6 +103,10 @@ module Backlex
87
103
  req["Authorization"] = "Bearer #{@app_token}"
88
104
  end
89
105
  req["X-Backlex-Tenant"] = @tenant if @tenant
106
+ req["X-Backlex-Org"] = @org if @org
107
+ # Without this a call never appears in the admin Traces panel and cannot
108
+ # be stitched to the server spans it triggers.
109
+ req["traceparent"] = self.class.make_traceparent if @tracing
90
110
  end
91
111
 
92
112
  # Serialize a ListQuery hash into a URL query string (mirrors buildSearch in
data/lib/backlex.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # client = Backlex::Client.new("https://api.example.com", api_key: "pak_...")
7
7
  # posts = client.from("posts").query.where(Backlex::Filter.eq("published", true)).list
8
8
  module Backlex
9
- VERSION = "0.0.1"
9
+ VERSION = "0.1.0"
10
10
  end
11
11
 
12
12
  require_relative "backlex/error"
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - backlex
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-17 00:00:00.000000000 Z
11
+ date: 2026-08-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A thin, typed wrapper over the backlex REST + SSE API. Zero runtime dependencies
14
14
  (stdlib net/http + json).
15
- email:
15
+ email:
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
@@ -34,7 +34,7 @@ licenses:
34
34
  metadata:
35
35
  documentation_uri: https://backlex.com/docs/client-sdks
36
36
  source_code_uri: https://github.com/backlex/backlex
37
- post_install_message:
37
+ post_install_message:
38
38
  rdoc_options: []
39
39
  require_paths:
40
40
  - lib
@@ -49,8 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.0.3.1
53
- signing_key:
52
+ rubygems_version: 3.5.22
53
+ signing_key:
54
54
  specification_version: 4
55
55
  summary: Official Ruby client for the backlex API (CRUD, query builder, auth, realtime,
56
56
  storage).