smplkit 3.0.23 → 3.0.24

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: 3e85fd7fac73ac4413a382782c353db02d602232de188ed1c8a9b7a1c53fcc78
4
- data.tar.gz: '04096b74f6d24e798c3eff83a53bad846786f4a077503db5c4c826676a0bfc69'
3
+ metadata.gz: e01aa3cb437ae82f20a01f1e0c8db011df81743411217757e0f7bebebd0210c1
4
+ data.tar.gz: 885c582b378994dae192d1453020e211e97a3552c5938a695c1fae9e3e316d56
5
5
  SHA512:
6
- metadata.gz: 50cb93abf4662d156a38e6609bee9932a8079514d30853485e13b517b7f524b4e4fa9cade5ab36fefa90becfdba5964ae46d6c38afb92df19f9f5fd11c6611b1
7
- data.tar.gz: cafaee08710826d6238eaec8e552f25dc0a987ab062c84629a84d340ba73001045b8097b35963f19c31adc55d7895b7d2ca881d9cc29570065f694e8e6962ff3
6
+ metadata.gz: 4eb6729884abcc3a25a82355c426a316b10beef8ecd0fe7f2cbecf96d1a94644730086348bf35c826600cd8a36c3c604aeb495ceada93c0e3471e62a7c8d9cd5
7
+ data.tar.gz: 8235e725b934305e260595371f2bc330bd409a33a0bb965f2002349f564467891f1afe3777609b5caa1a7b2d423c459d3bcec0abdacb250d1446e205da0675de
@@ -386,10 +386,14 @@ module Smplkit
386
386
  # response (including newly-assigned +id+, +created_at+, +updated_at+,
387
387
  # +version+).
388
388
  #
389
+ # @raise [ArgumentError] when {#transform} and {#transform_type} are not
390
+ # both nil or both set, or when {#transform_type} is +JSONATA+ and
391
+ # {#transform} is not a +String+.
389
392
  # @return [self]
390
393
  def save
391
394
  raise "Forwarder was constructed without a client; cannot save" if @client.nil?
392
395
 
396
+ self.class.send(:validate_transform_pair!, @transform, @transform_type)
393
397
  updated = @created_at.nil? ? @client._create_forwarder(self) : @client._update_forwarder(self)
394
398
  _apply(updated)
395
399
  self
@@ -423,6 +427,26 @@ module Smplkit
423
427
  @version = other.version
424
428
  end
425
429
 
430
+ # Validate the +(transform, transform_type)+ pair.
431
+ #
432
+ # Both must be nil or both must be set. When +transform_type+ is
433
+ # +TransformType::JSONATA+, +transform+ must be a +String+ (the
434
+ # JSONata expression). Other engines accept any value.
435
+ #
436
+ # @api private
437
+ def self.validate_transform_pair!(transform, transform_type)
438
+ if transform.nil? != transform_type.nil?
439
+ raise ArgumentError,
440
+ "transform and transform_type must be specified together (both nil or both set)"
441
+ end
442
+ return if transform.nil?
443
+ return unless transform_type == TransformType::JSONATA && !transform.is_a?(String)
444
+
445
+ raise ArgumentError,
446
+ "transform must be a String when transform_type is JSONATA " \
447
+ "(got #{transform.class})"
448
+ end
449
+
426
450
  def self.from_resource(resource, client: nil)
427
451
  a = resource.attributes
428
452
  new(
@@ -44,23 +44,22 @@ module Smplkit
44
44
  # @param filter [Hash, nil] Optional JSON Logic filter; events that don't
45
45
  # match are recorded as +filtered_out+ deliveries.
46
46
  # @param transform [Object, nil] Optional template applied to each event
47
- # before delivery. Free-form — the audit service passes the value
48
- # verbatim to the engine named by +transform_type+. Must be paired with
49
- # a non-nil +transform_type+.
47
+ # before delivery. Free-form by default — the audit service passes the
48
+ # value verbatim to the engine named by +transform_type+. Must be paired
49
+ # with a non-nil +transform_type+; when +transform_type+ is
50
+ # +TransformType::JSONATA+, +transform+ must be a +String+ (the JSONata
51
+ # expression).
50
52
  # @param transform_type [String, nil] Engine that evaluates +transform+ —
51
- # one of {Smplkit::Audit::TransformType::VALUES}. Required when
52
- # +transform+ is provided.
53
- # @raise [ArgumentError] when +transform+ is set but +transform_type+ is nil.
53
+ # one of {Smplkit::Audit::TransformType::VALUES}. Must be paired with a
54
+ # non-nil +transform+.
55
+ # @raise [ArgumentError] when +transform+ and +transform_type+ are not both
56
+ # nil or both set, or when +transform_type+ is +JSONATA+ and +transform+
57
+ # is not a +String+.
54
58
  # @return [Smplkit::Audit::Forwarder]
55
59
  def new_forwarder(name:, forwarder_type:, configuration:,
56
60
  enabled: true, description: nil,
57
61
  filter: nil, transform: nil, transform_type: nil)
58
- if !transform.nil? && transform_type.nil?
59
- raise ArgumentError,
60
- "transform_type is required when transform is provided " \
61
- "(one of #{Smplkit::Audit::TransformType::VALUES.inspect})"
62
- end
63
-
62
+ Smplkit::Audit::Forwarder.send(:validate_transform_pair!, transform, transform_type)
64
63
  Smplkit::Audit::Forwarder.new(
65
64
  self,
66
65
  name: name,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smplkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.23
4
+ version: 3.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smpl Solutions LLC