smplkit 3.0.22 → 3.0.23
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/lib/smplkit/audit/models.rb +37 -10
- data/lib/smplkit/log_level.rb +7 -7
- data/lib/smplkit/management/audit.rb +17 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e85fd7fac73ac4413a382782c353db02d602232de188ed1c8a9b7a1c53fcc78
|
|
4
|
+
data.tar.gz: '04096b74f6d24e798c3eff83a53bad846786f4a077503db5c4c826676a0bfc69'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 50cb93abf4662d156a38e6609bee9932a8079514d30853485e13b517b7f524b4e4fa9cade5ab36fefa90becfdba5964ae46d6c38afb92df19f9f5fd11c6611b1
|
|
7
|
+
data.tar.gz: cafaee08710826d6238eaec8e552f25dc0a987ab062c84629a84d340ba73001045b8097b35963f19c31adc55d7895b7d2ca881d9cc29570065f694e8e6962ff3
|
data/lib/smplkit/audit/models.rb
CHANGED
|
@@ -113,6 +113,32 @@ module Smplkit
|
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
+
# Engine that evaluates a forwarder's +transform+ template
|
|
117
|
+
# (ADR-047 §2.12). Only +JSONATA+ is supported today; the enum
|
|
118
|
+
# exists so the field is typed instead of accepting any string,
|
|
119
|
+
# and so additional engines can be added without breaking the
|
|
120
|
+
# public surface.
|
|
121
|
+
module TransformType
|
|
122
|
+
JSONATA = "JSONATA"
|
|
123
|
+
|
|
124
|
+
VALUES = [JSONATA].freeze
|
|
125
|
+
|
|
126
|
+
# Validate and normalize an input to a wire-format string.
|
|
127
|
+
#
|
|
128
|
+
# @param value [String, nil] a published constant or its literal string.
|
|
129
|
+
# @return [String, nil] the canonical wire value (or +nil+ when input is +nil+).
|
|
130
|
+
# @raise [ArgumentError] when +value+ is not a member of {VALUES}.
|
|
131
|
+
def self.coerce(value)
|
|
132
|
+
return nil if value.nil?
|
|
133
|
+
|
|
134
|
+
s = value.to_s
|
|
135
|
+
return s if VALUES.include?(s)
|
|
136
|
+
|
|
137
|
+
raise ArgumentError,
|
|
138
|
+
"Unknown TransformType #{value.inspect}; expected one of #{VALUES.inspect}"
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
116
142
|
# A single audit event as returned by the audit service (ADR-047 §2.3.1).
|
|
117
143
|
#
|
|
118
144
|
# @!attribute [rw] id
|
|
@@ -128,12 +154,11 @@ module Smplkit
|
|
|
128
154
|
# @!attribute [rw] created_at
|
|
129
155
|
# @return [String] ISO-8601 timestamp of when the audit service first ingested this event.
|
|
130
156
|
# @!attribute [rw] actor_type
|
|
131
|
-
# @return [String, nil]
|
|
157
|
+
# @return [String, nil] Customer-supplied free-form actor type string — +nil+ when not provided.
|
|
132
158
|
# @!attribute [rw] actor_id
|
|
133
|
-
# @return [String, nil]
|
|
134
|
-
# +nil+ for system or anonymous events.
|
|
159
|
+
# @return [String, nil] Customer-supplied free-form actor identifier — +nil+ when not provided.
|
|
135
160
|
# @!attribute [rw] actor_label
|
|
136
|
-
# @return [String, nil]
|
|
161
|
+
# @return [String, nil] Customer-supplied display label for the actor — typically a name or email.
|
|
137
162
|
# @!attribute [rw] data
|
|
138
163
|
# @return [Hash{String => Object}] Free-form per-event payload defined by the customer.
|
|
139
164
|
# @!attribute [rw] idempotency_key
|
|
@@ -310,13 +335,15 @@ module Smplkit
|
|
|
310
335
|
# deliveries instead of being delivered to the destination.
|
|
311
336
|
attr_accessor :filter
|
|
312
337
|
|
|
313
|
-
# @return [
|
|
314
|
-
# delivery.
|
|
315
|
-
#
|
|
338
|
+
# @return [Object, nil] Optional template applied to each event before
|
|
339
|
+
# delivery. Free-form — the audit service passes the value verbatim to
|
|
340
|
+
# the engine named by {#transform_type}. For +TransformType::JSONATA+ a
|
|
341
|
+
# JSONata expression string; +nil+ delivers the event JSON as-is. Must
|
|
342
|
+
# be paired with a non-nil {#transform_type}.
|
|
316
343
|
attr_accessor :transform
|
|
317
344
|
|
|
318
|
-
# @return [String, nil] Engine that evaluates {#transform}
|
|
319
|
-
#
|
|
345
|
+
# @return [String, nil] Engine that evaluates {#transform} — one of
|
|
346
|
+
# {TransformType::VALUES}. Required whenever {#transform} is set.
|
|
320
347
|
attr_accessor :transform_type
|
|
321
348
|
|
|
322
349
|
# @return [String, nil] ISO-8601 timestamp of first persist. +nil+ for an unsaved instance.
|
|
@@ -344,7 +371,7 @@ module Smplkit
|
|
|
344
371
|
@description = description
|
|
345
372
|
@filter = filter
|
|
346
373
|
@transform = transform
|
|
347
|
-
@transform_type = transform_type
|
|
374
|
+
@transform_type = TransformType.coerce(transform_type)
|
|
348
375
|
@created_at = created_at
|
|
349
376
|
@updated_at = updated_at
|
|
350
377
|
@deleted_at = deleted_at
|
data/lib/smplkit/log_level.rb
CHANGED
|
@@ -5,10 +5,10 @@ module Smplkit
|
|
|
5
5
|
#
|
|
6
6
|
# Acts as a string-valued enum: each constant equals its name when used in
|
|
7
7
|
# string contexts, and supports comparison via the +ordinal+. Members are
|
|
8
|
-
# declared in
|
|
9
|
-
#
|
|
8
|
+
# declared in increasing severity order — matching the Ruby stdlib
|
|
9
|
+
# +Logger+ convention (TRACE = least severe, SILENT = most severe).
|
|
10
10
|
class LogLevel
|
|
11
|
-
NAMES = %w[DEBUG ERROR FATAL
|
|
11
|
+
NAMES = %w[TRACE DEBUG INFO WARN ERROR FATAL SILENT].freeze
|
|
12
12
|
|
|
13
13
|
# @return [String] Canonical level name (e.g. +"INFO"+).
|
|
14
14
|
attr_reader :name
|
|
@@ -32,15 +32,15 @@ module Smplkit
|
|
|
32
32
|
|
|
33
33
|
include Comparable
|
|
34
34
|
|
|
35
|
+
TRACE = new("TRACE", 0)
|
|
35
36
|
DEBUG = new("DEBUG", 1)
|
|
37
|
+
INFO = new("INFO", 2)
|
|
38
|
+
WARN = new("WARN", 3)
|
|
36
39
|
ERROR = new("ERROR", 4)
|
|
37
40
|
FATAL = new("FATAL", 5)
|
|
38
|
-
INFO = new("INFO", 2)
|
|
39
41
|
SILENT = new("SILENT", 6)
|
|
40
|
-
TRACE = new("TRACE", 0)
|
|
41
|
-
WARN = new("WARN", 3)
|
|
42
42
|
|
|
43
|
-
ALL = [
|
|
43
|
+
ALL = [TRACE, DEBUG, INFO, WARN, ERROR, FATAL, SILENT].freeze
|
|
44
44
|
|
|
45
45
|
BY_NAME = ALL.to_h { |lvl| [lvl.name, lvl] }.freeze
|
|
46
46
|
|
|
@@ -43,12 +43,24 @@ module Smplkit
|
|
|
43
43
|
# @param description [String, nil] Optional free-text description.
|
|
44
44
|
# @param filter [Hash, nil] Optional JSON Logic filter; events that don't
|
|
45
45
|
# match are recorded as +filtered_out+ deliveries.
|
|
46
|
-
# @param transform [
|
|
47
|
-
#
|
|
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+.
|
|
50
|
+
# @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.
|
|
48
54
|
# @return [Smplkit::Audit::Forwarder]
|
|
49
55
|
def new_forwarder(name:, forwarder_type:, configuration:,
|
|
50
56
|
enabled: true, description: nil,
|
|
51
|
-
filter: nil, transform: nil)
|
|
57
|
+
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
|
+
|
|
52
64
|
Smplkit::Audit::Forwarder.new(
|
|
53
65
|
self,
|
|
54
66
|
name: name,
|
|
@@ -58,7 +70,7 @@ module Smplkit
|
|
|
58
70
|
description: description,
|
|
59
71
|
filter: filter,
|
|
60
72
|
transform: transform,
|
|
61
|
-
transform_type:
|
|
73
|
+
transform_type: transform_type
|
|
62
74
|
)
|
|
63
75
|
end
|
|
64
76
|
|
|
@@ -134,7 +146,7 @@ module Smplkit
|
|
|
134
146
|
forwarder_type: Smplkit::Audit::ForwarderType.coerce(forwarder.forwarder_type),
|
|
135
147
|
enabled: forwarder.enabled,
|
|
136
148
|
filter: forwarder.filter,
|
|
137
|
-
transform_type: forwarder.transform_type,
|
|
149
|
+
transform_type: Smplkit::Audit::TransformType.coerce(forwarder.transform_type),
|
|
138
150
|
transform: forwarder.transform,
|
|
139
151
|
configuration: Smplkit::Audit::HttpConfiguration.to_wire(forwarder.configuration)
|
|
140
152
|
)
|