axhub-sdk 0.1.0 → 0.3.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.
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Ergonomic data layer for the AX Hub Ruby SDK.
4
+ #
5
+ # Public surface (mirrors the node `resources/data` layer):
6
+ #
7
+ # client.tenant(tenant_slug).app(app_slug).data.table(name_or_schema)
8
+ # client.tenant(tenant_slug).app(app_slug).data.discover(table)
9
+ #
10
+ # returns a DataTableClient with list / list_all / count / get / insert /
11
+ # insert_many / update / delete, plus the predicate DSL (where(col).eq(v) /
12
+ # and_(...) / block form), define_schema(...), and offset-only pagination.
13
+ require_relative 'data/errors'
14
+ require_relative 'data/dsl/schema'
15
+ require_relative 'data/dsl/ops'
16
+ require_relative 'data/dsl/validation'
17
+ require_relative 'data/pagination'
18
+ require_relative 'data/projection'
19
+ require_relative 'data/where_serializer'
20
+ require_relative 'data/schema_cache'
21
+ require_relative 'data/discover'
22
+ require_relative 'data/client'
23
+
24
+ module AxHub
25
+ module Data
26
+ # Fluent scope wrappers so the public chain reads `client.tenant(t).app(a).data`
27
+ # (mirrors node/python, where `.data` on the app scope yields the ergonomic
28
+ # AppDataFactory). `client.data` itself stays the operation-id OperationClient.
29
+ class AppScope
30
+ attr_reader :data
31
+
32
+ def initialize(ergo_data, tenant_slug, app_slug)
33
+ # `ergo_data` is the single per-client DataClient (memoized on Client), so
34
+ # its schema cache persists across every tenant().app() chain — node parity.
35
+ @data = ergo_data.scoped(tenant_slug).app(app_slug)
36
+ end
37
+ end
38
+
39
+ class TenantScope
40
+ def initialize(ergo_data, tenant_slug)
41
+ @ergo_data = ergo_data
42
+ @tenant_slug = tenant_slug
43
+ end
44
+
45
+ def app(app_slug)
46
+ AppScope.new(@ergo_data, @tenant_slug, app_slug)
47
+ end
48
+ end
49
+ end
50
+
51
+ # --- Ergonomic data layer fluent surface (mirrors node client.tenant().app().data) ---
52
+ # `client.data` stays the operation-id route-table OperationClient (the
53
+ # conformance vectors + e2e tests depend on it). The ergonomic data layer is
54
+ # reached only through the tenant/app fluent chain, exactly as in node/python.
55
+ class Client
56
+ # The single per-client ergonomic DataClient, lazily memoized so the schema
57
+ # cache (TTL/negative-TTL/LRU) survives across tenant().app() chains (mirrors
58
+ # node, where `data` is one per-SDK DataClient).
59
+ def ergo_data
60
+ @ergo_data ||= AxHub::Data::DataClient.new(self, schema_cache: @schema_cache_opt)
61
+ end
62
+
63
+ def tenant(tenant_slug)
64
+ AxHub::Data::TenantScope.new(ergo_data, tenant_slug)
65
+ end
66
+ end
67
+ end
@@ -16,7 +16,7 @@ module AxHub
16
16
  end
17
17
 
18
18
  class Client
19
- attr_reader :identity, :tenants, :authz, :audit, :gateway, :data, :deployments
19
+ attr_reader :identity, :tenants, :authz, :audit, :gateway, :cost, :data, :deployments
20
20
  alias __axhub_original_initialize initialize unless method_defined?(:__axhub_original_initialize)
21
21
  def initialize(*args, **kwargs)
22
22
  __axhub_original_initialize(*args, **kwargs)
@@ -25,6 +25,7 @@ module AxHub
25
25
  @authz = OperationClient.new(self)
26
26
  @audit = OperationClient.new(self)
27
27
  @gateway = OperationClient.new(self)
28
+ @cost = OperationClient.new(self)
28
29
  @data = OperationClient.new(self)
29
30
  @deployments = OperationClient.new(self)
30
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AxHub
4
- VERSION = '0.1.0'
4
+ VERSION = '0.3.0'
5
5
  end