schematichq 1.5.2 → 1.5.3
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/.fern/metadata.json +3 -3
- data/.fern/replay.lock +8 -338
- data/.fernignore +6 -0
- data/README.md +141 -0
- data/custom.gemspec.rb +6 -0
- data/lib/schematic/accounts/types/update_environment_request_body.rb +2 -0
- data/lib/schematic/client.rb +1 -1
- data/lib/schematic/credits/client.rb +50 -6
- data/lib/schematic/credits/leases/check.rb +477 -0
- data/lib/schematic/credits/leases/lease_manager.rb +565 -0
- data/lib/schematic/credits/leases/lease_store.rb +240 -0
- data/lib/schematic/credits/leases/redis_lease_store.rb +358 -0
- data/lib/schematic/credits/leases/redis_reservation_store.rb +326 -0
- data/lib/schematic/credits/leases/reservation_store.rb +161 -0
- data/lib/schematic/credits/leases/server_check.rb +237 -0
- data/lib/schematic/credits/leases/track.rb +66 -0
- data/lib/schematic/credits/leases/types.rb +329 -0
- data/lib/schematic/credits/leases/wire_client.rb +83 -0
- data/lib/schematic/credits/types/acquire_credit_lease_request_body.rb +2 -0
- data/lib/schematic/credits/types/create_credit_spend_policy_request_body.rb +5 -1
- data/lib/schematic/credits/types/extend_credit_lease_request_body.rb +2 -0
- data/lib/schematic/credits/types/get_credit_spend_policy_usage_params.rb +16 -0
- data/lib/schematic/credits/types/get_credit_spend_policy_usage_request.rb +15 -0
- data/lib/schematic/credits/types/get_credit_spend_policy_usage_response.rb +13 -0
- data/lib/schematic/credits/types/update_credit_spend_policy_request_body.rb +4 -0
- data/lib/schematic/datastream/client.rb +32 -2
- data/lib/schematic/entitlements/client.rb +165 -0
- data/lib/schematic/entitlements/types/count_company_user_usage_params.rb +24 -0
- data/lib/schematic/entitlements/types/count_company_user_usage_request.rb +23 -0
- data/lib/schematic/entitlements/types/count_company_user_usage_response.rb +13 -0
- data/lib/schematic/entitlements/types/get_company_user_usage_metrics_params.rb +16 -0
- data/lib/schematic/entitlements/types/get_company_user_usage_metrics_request.rb +15 -0
- data/lib/schematic/entitlements/types/get_company_user_usage_metrics_response.rb +13 -0
- data/lib/schematic/entitlements/types/list_company_user_usage_params.rb +24 -0
- data/lib/schematic/entitlements/types/list_company_user_usage_request.rb +23 -0
- data/lib/schematic/entitlements/types/list_company_user_usage_response.rb +13 -0
- data/lib/schematic/plangroups/client.rb +2 -0
- data/lib/schematic/plangroups/types/create_plan_group_request_body.rb +2 -0
- data/lib/schematic/plangroups/types/update_plan_group_request_body.rb +2 -0
- data/lib/schematic/planmigrations/client.rb +6 -0
- data/lib/schematic/planmigrations/types/count_migrations_params.rb +2 -0
- data/lib/schematic/planmigrations/types/count_migrations_request.rb +2 -0
- data/lib/schematic/planmigrations/types/create_migration_input.rb +2 -0
- data/lib/schematic/planmigrations/types/list_migrations_params.rb +2 -0
- data/lib/schematic/planmigrations/types/list_migrations_request.rb +2 -0
- data/lib/schematic/plans/types/publish_plan_version_request_body.rb +4 -0
- data/lib/schematic/plans/types/retry_custom_plan_billing_request_body.rb +2 -0
- data/lib/schematic/rules_engine.rb +37 -0
- data/lib/schematic/schematic_client.rb +830 -33
- data/lib/schematic/types/capture_raw_event.rb +4 -0
- data/lib/schematic/types/check_flags_response_data.rb +2 -0
- data/lib/schematic/types/company_detail_response_data.rb +2 -0
- data/lib/schematic/types/company_plan_detail_response_data.rb +2 -0
- data/lib/schematic/types/company_user_usage_metrics_response_data.rb +15 -0
- data/lib/schematic/types/company_user_usage_response_data.rb +19 -0
- data/lib/schematic/types/company_user_usage_row_response_data.rb +17 -0
- data/lib/schematic/types/component_display_settings.rb +2 -0
- data/lib/schematic/types/component_settings_response_data.rb +2 -0
- data/lib/schematic/types/credit_event_ledger_response_data.rb +5 -1
- data/lib/schematic/types/credit_event_type.rb +3 -0
- data/lib/schematic/types/credit_ledger_entry_kind.rb +17 -0
- data/lib/schematic/types/credit_spend_policy.rb +25 -0
- data/lib/schematic/types/credit_spend_policy_response_data.rb +12 -0
- data/lib/schematic/types/credit_spend_window.rb +11 -0
- data/lib/schematic/types/credit_spend_window_unit.rb +13 -0
- data/lib/schematic/types/custom_plan_billing_response_data.rb +2 -0
- data/lib/schematic/types/environment_detail_response_data.rb +2 -0
- data/lib/schematic/types/environment_response_data.rb +2 -0
- data/lib/schematic/types/estimated_plan_total.rb +13 -0
- data/lib/schematic/types/pending_migration_response_data.rb +6 -0
- data/lib/schematic/types/plan_version_migration_response_data.rb +2 -0
- data/lib/schematic/types/plan_version_migration_strategy.rb +1 -0
- data/lib/schematic/types/rules_engine_schema_version.rb +1 -1
- data/lib/schematic/types/rulesengine_company.rb +2 -0
- data/lib/schematic/types/rulesengine_credit_spend_policy.rb +25 -0
- data/lib/schematic/types/rulesengine_credit_spend_policy_scope.rb +13 -0
- data/lib/schematic/types/rulesengine_credit_spend_window.rb +11 -0
- data/lib/schematic/types/rulesengine_user.rb +2 -0
- data/lib/schematic/types/user_usage_metric.rb +12 -0
- data/lib/schematic/version.rb +1 -1
- data/lib/schematic.rb +26 -2
- data/lib/schematichq.rb +10 -0
- data/reference.md +474 -9
- metadata +36 -2
|
@@ -159,6 +159,7 @@ module Schematic
|
|
|
159
159
|
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
160
160
|
# @option request_options [Integer] :timeout_in_seconds
|
|
161
161
|
# @option params [String, nil] :feature_id
|
|
162
|
+
# @option params [String, nil] :feature_plan_rollout_id
|
|
162
163
|
# @option params [String, nil] :plan_version_id
|
|
163
164
|
# @option params [Schematic::Types::PlanVersionMigrationStatus, nil] :status
|
|
164
165
|
# @option params [Integer, nil] :limit
|
|
@@ -167,6 +168,7 @@ module Schematic
|
|
|
167
168
|
# @example
|
|
168
169
|
# client.planmigrations.list_migrations(
|
|
169
170
|
# feature_id: "feature_id",
|
|
171
|
+
# feature_plan_rollout_id: "feature_plan_rollout_id",
|
|
170
172
|
# plan_version_id: "plan_version_id",
|
|
171
173
|
# status: "cancelled",
|
|
172
174
|
# limit: 1000000,
|
|
@@ -178,6 +180,7 @@ module Schematic
|
|
|
178
180
|
params = Schematic::Internal::Types::Utils.normalize_keys(params)
|
|
179
181
|
query_params = {}
|
|
180
182
|
query_params["feature_id"] = params[:feature_id] if params.key?(:feature_id)
|
|
183
|
+
query_params["feature_plan_rollout_id"] = params[:feature_plan_rollout_id] if params.key?(:feature_plan_rollout_id)
|
|
181
184
|
query_params["plan_version_id"] = params[:plan_version_id] if params.key?(:plan_version_id)
|
|
182
185
|
query_params["status"] = params[:status] if params.key?(:status)
|
|
183
186
|
query_params["limit"] = params[:limit] if params.key?(:limit)
|
|
@@ -405,6 +408,7 @@ module Schematic
|
|
|
405
408
|
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
406
409
|
# @option request_options [Integer] :timeout_in_seconds
|
|
407
410
|
# @option params [String, nil] :feature_id
|
|
411
|
+
# @option params [String, nil] :feature_plan_rollout_id
|
|
408
412
|
# @option params [String, nil] :plan_version_id
|
|
409
413
|
# @option params [Schematic::Types::PlanVersionMigrationStatus, nil] :status
|
|
410
414
|
# @option params [Integer, nil] :limit
|
|
@@ -413,6 +417,7 @@ module Schematic
|
|
|
413
417
|
# @example
|
|
414
418
|
# client.planmigrations.count_migrations(
|
|
415
419
|
# feature_id: "feature_id",
|
|
420
|
+
# feature_plan_rollout_id: "feature_plan_rollout_id",
|
|
416
421
|
# plan_version_id: "plan_version_id",
|
|
417
422
|
# status: "cancelled",
|
|
418
423
|
# limit: 1000000,
|
|
@@ -424,6 +429,7 @@ module Schematic
|
|
|
424
429
|
params = Schematic::Internal::Types::Utils.normalize_keys(params)
|
|
425
430
|
query_params = {}
|
|
426
431
|
query_params["feature_id"] = params[:feature_id] if params.key?(:feature_id)
|
|
432
|
+
query_params["feature_plan_rollout_id"] = params[:feature_plan_rollout_id] if params.key?(:feature_plan_rollout_id)
|
|
427
433
|
query_params["plan_version_id"] = params[:plan_version_id] if params.key?(:plan_version_id)
|
|
428
434
|
query_params["status"] = params[:status] if params.key?(:status)
|
|
429
435
|
query_params["limit"] = params[:limit] if params.key?(:limit)
|
|
@@ -7,6 +7,8 @@ module Schematic
|
|
|
7
7
|
class CountMigrationsParams < Internal::Types::Model
|
|
8
8
|
field :feature_id, -> { String }, optional: true, nullable: false
|
|
9
9
|
|
|
10
|
+
field :feature_plan_rollout_id, -> { String }, optional: true, nullable: false
|
|
11
|
+
|
|
10
12
|
field :limit, -> { Integer }, optional: true, nullable: false
|
|
11
13
|
|
|
12
14
|
field :offset, -> { Integer }, optional: true, nullable: false
|
|
@@ -6,6 +6,8 @@ module Schematic
|
|
|
6
6
|
class CountMigrationsRequest < Internal::Types::Model
|
|
7
7
|
field :feature_id, -> { String }, optional: true, nullable: false
|
|
8
8
|
|
|
9
|
+
field :feature_plan_rollout_id, -> { String }, optional: true, nullable: false
|
|
10
|
+
|
|
9
11
|
field :plan_version_id, -> { String }, optional: true, nullable: false
|
|
10
12
|
|
|
11
13
|
field :status, -> { Schematic::Types::PlanVersionMigrationStatus }, optional: true, nullable: false
|
|
@@ -16,6 +16,8 @@ module Schematic
|
|
|
16
16
|
|
|
17
17
|
field :proration_behavior, -> { Schematic::Types::MigrationProrationBehavior }, optional: true, nullable: false
|
|
18
18
|
|
|
19
|
+
field :scheduled_at, -> { String }, optional: true, nullable: false
|
|
20
|
+
|
|
19
21
|
field :strategy, -> { Schematic::Types::PlanVersionMigrationStrategy }, optional: false, nullable: false
|
|
20
22
|
|
|
21
23
|
field :target_plan_type, -> { Schematic::Types::PlanType }, optional: false, nullable: false
|
|
@@ -7,6 +7,8 @@ module Schematic
|
|
|
7
7
|
class ListMigrationsParams < Internal::Types::Model
|
|
8
8
|
field :feature_id, -> { String }, optional: true, nullable: false
|
|
9
9
|
|
|
10
|
+
field :feature_plan_rollout_id, -> { String }, optional: true, nullable: false
|
|
11
|
+
|
|
10
12
|
field :limit, -> { Integer }, optional: true, nullable: false
|
|
11
13
|
|
|
12
14
|
field :offset, -> { Integer }, optional: true, nullable: false
|
|
@@ -6,6 +6,8 @@ module Schematic
|
|
|
6
6
|
class ListMigrationsRequest < Internal::Types::Model
|
|
7
7
|
field :feature_id, -> { String }, optional: true, nullable: false
|
|
8
8
|
|
|
9
|
+
field :feature_plan_rollout_id, -> { String }, optional: true, nullable: false
|
|
10
|
+
|
|
9
11
|
field :plan_version_id, -> { String }, optional: true, nullable: false
|
|
10
12
|
|
|
11
13
|
field :status, -> { Schematic::Types::PlanVersionMigrationStatus }, optional: true, nullable: false
|
|
@@ -12,6 +12,8 @@ module Schematic
|
|
|
12
12
|
|
|
13
13
|
field :billing_cycle_anchor, -> { String }, optional: true, nullable: false
|
|
14
14
|
|
|
15
|
+
field :billing_start_date, -> { String }, optional: true, nullable: false
|
|
16
|
+
|
|
15
17
|
field :coupon_external_id, -> { String }, optional: true, nullable: false
|
|
16
18
|
|
|
17
19
|
field :custom_field_values, -> { Internal::Types::Array[Schematic::Types::CheckoutFieldValue] }, optional: true, nullable: false
|
|
@@ -32,6 +34,8 @@ module Schematic
|
|
|
32
34
|
|
|
33
35
|
field :require_no_migration, -> { Internal::Types::Boolean }, optional: true, nullable: false
|
|
34
36
|
|
|
37
|
+
field :scheduled_at, -> { String }, optional: true, nullable: false
|
|
38
|
+
|
|
35
39
|
field :send_invoice, -> { Internal::Types::Boolean }, optional: true, nullable: false
|
|
36
40
|
|
|
37
41
|
field :tax_id, -> { Schematic::Types::TaxIdInput }, optional: true, nullable: false
|
|
@@ -10,6 +10,8 @@ module Schematic
|
|
|
10
10
|
|
|
11
11
|
field :billing_cycle_anchor, -> { String }, optional: true, nullable: false
|
|
12
12
|
|
|
13
|
+
field :billing_start_date, -> { String }, optional: true, nullable: false
|
|
14
|
+
|
|
13
15
|
field :customer_email, -> { String }, optional: false, nullable: false
|
|
14
16
|
|
|
15
17
|
field :days_until_due, -> { Integer }, optional: true, nullable: false
|
|
@@ -73,12 +73,26 @@ module Schematic
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def check_flag(flag, company = nil, user = nil)
|
|
76
|
+
check_flag_with_options(flag, company, user, nil)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Evaluate a flag with preflight options: a simulated usage, an event-scoped
|
|
80
|
+
# usage, or a pre-computed per-credit cost. The engine applies them to the
|
|
81
|
+
# conditions they match without mutating any state, so a caller can ask
|
|
82
|
+
# "would this call still be allowed after it lands".
|
|
83
|
+
#
|
|
84
|
+
# options is a hash with any of :credit_cost (credit id to cost),
|
|
85
|
+
# :usage, and :event_usage ({ event_subtype:, quantity: }). The engine reads
|
|
86
|
+
# them snake_case in both directions, so they go on the envelope as given.
|
|
87
|
+
def check_flag_with_options(flag, company = nil, user = nil, options = nil)
|
|
76
88
|
raise "WASM rules engine not initialized" unless @initialized
|
|
77
89
|
|
|
78
90
|
# Build combined JSON envelope (same format as Python/C#)
|
|
79
91
|
envelope = { flag: strip_nulls(flag) }
|
|
80
92
|
envelope[:company] = strip_nulls(company) if company
|
|
81
93
|
envelope[:user] = strip_nulls(user) if user
|
|
94
|
+
# Omitted entirely when empty, so the engine uses its own defaults.
|
|
95
|
+
envelope[:options] = strip_nulls(engine_options(options)) if options && !options.empty?
|
|
82
96
|
|
|
83
97
|
json_bytes = JSON.generate(envelope).encode("UTF-8")
|
|
84
98
|
|
|
@@ -123,6 +137,29 @@ module Schematic
|
|
|
123
137
|
|
|
124
138
|
private
|
|
125
139
|
|
|
140
|
+
# The options as the engine takes them. usage and event_usage.quantity
|
|
141
|
+
# deserialize as i64 there, so a value with a decimal point fails the whole
|
|
142
|
+
# check. Rounded through the helper every other wire field uses, so a caller
|
|
143
|
+
# passing a preflight straight to check_flag_with_entitlement is asked the
|
|
144
|
+
# same question a lease check asks, and an infinite usage is handed over
|
|
145
|
+
# rather than raising out of ceil.
|
|
146
|
+
def engine_options(options)
|
|
147
|
+
out = options.dup
|
|
148
|
+
usage_key = out.key?(:usage) ? :usage : "usage"
|
|
149
|
+
out[usage_key] = Credits::Leases.wire_quantity(out[usage_key]) if out[usage_key].is_a?(Numeric)
|
|
150
|
+
event_key = out.key?(:event_usage) ? :event_usage : "event_usage"
|
|
151
|
+
event_usage = out[event_key]
|
|
152
|
+
return out unless event_usage.is_a?(Hash)
|
|
153
|
+
|
|
154
|
+
quantity_key = event_usage.key?(:quantity) ? :quantity : "quantity"
|
|
155
|
+
return out unless event_usage[quantity_key].is_a?(Numeric)
|
|
156
|
+
|
|
157
|
+
out[event_key] = event_usage.merge(
|
|
158
|
+
quantity_key => Credits::Leases.wire_quantity(event_usage[quantity_key])
|
|
159
|
+
)
|
|
160
|
+
out
|
|
161
|
+
end
|
|
162
|
+
|
|
126
163
|
def export_func(name)
|
|
127
164
|
exp = @instance.export(name)
|
|
128
165
|
raise "WASM export '#{name}' not found" unless exp
|