aws-lex-conversation 4.0.0 → 4.2.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: f57f415463cb7d78d0ddb4f48232b1c0038bc91e4813fb9d6de6455fa7f0a4d9
4
- data.tar.gz: 7ba9cdf27e3f2368862bc7584eb1ce555a24a253d2a1ce3dd4c1d8500264fd0c
3
+ metadata.gz: 10b9a6aa5e59e3f2c016255c6fbd46f30631ece6c981fa81d45c2b300f676041
4
+ data.tar.gz: a49c289a1c5cf5189f3f87e971a32947dc5ab2a6380189b39c8544c1d5792c20
5
5
  SHA512:
6
- metadata.gz: 168eb69456d693dbf0f2618a23e4ec13fef7daca4921871b2d0b5a532ef39f4a1fdceb435b3122518aee7e4ae9495546b85f58e4d95bceab255fb2b91f8fcfc6
7
- data.tar.gz: 2d9577a331c617a681c3f961daaa1d1825812c907f6d40ebe838db4ce471b37ea948d9f0b75985430795d449ffcf4a59968180a591f9cfbc66a8f115864d75eb
6
+ metadata.gz: c94e997fba06c3658c53d0a51dd4b67a0c3f75118fddd7ba0430ecba2e8433d4e601ba9da5e14d7307d200c97bdda47f74e35809b0e4ae95883c6572365e311e
7
+ data.tar.gz: 8734811c21883cc5ba09a234bbd04a1cd6fcf5b98f189406da843c30ea631c19fc0e32ae2a95a7bfdda6985f849ba4e2804f3e3897a3a46eebc9b2de6eb2396d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,47 @@
1
+ # 4.1.0 - July 21, 2021
2
+
3
+ * Don't set the `intent` property in the response for `ElicitIntent`
4
+ actions as the field is optional as per [AWS documentation](https://docs.aws.amazon.com/lexv2/latest/dg/lambda.html#lambda-response-format).
5
+ * Add `InProgress` and `ReadyForFulfillment` enumerations to `FulfillmentState`.
6
+
7
+ # 4.0.1 - July 16, 2021
8
+
9
+ * Fix a bug with the `Aws::Lex::Conversation::Handler::Echo` class because it
10
+ didn't correctly return an array of messages required for Lex V2.
11
+ * Drop a call to `Hash#deep_symbolize_keys` so we don't implicitly rely on
12
+ ActiveSupport.
13
+ * Call `Hash#compact` when transforming a Lex response so we don't include any
14
+ `nil` values in the response.
15
+
16
+ # 4.0.0 - July 14, 2021
17
+
18
+ **breaking change** - Drop support for the Lex runtime version 1. If you are using Lex Version 1, please lock this gem to `~> 3.0.0`.
19
+ **breaking change** - Implement support and types for [Lex Version 2](https://docs.aws.amazon.com/lexv2/latest/dg/what-is.html), which implements a new Lambda [input/output event format](https://docs.aws.amazon.com/lexv2/latest/dg/lambda.html#lambda-input-format).
20
+
21
+ # 3.1.0 - June 1, 2021
22
+
23
+ * Default both `request_attributes` and `session_attributes`
24
+ to an empty Hash when the values from the event are `null`.
25
+ It is much easier to reason and write logic when you can
26
+ assume that these values are always at least a hash.
27
+
28
+ # 3.0.0 - May 20, 2021
29
+
30
+ * **breaking change** - Don't pass the `recentIntentSummaryView` back
31
+ in the Lex response unless we have modified or added an existing
32
+ checkpoint. Lex will persist the previous intent summary/history
33
+ if we do not send a `recentIntentSummaryView` value back in the
34
+ response (see [1]).
35
+ * Add a few helper methods to the `Aws::Lex::Conversation::Type::Slot`
36
+ instances:
37
+
38
+ - `active?`: returns true if the slot is defined (either optional or
39
+ required) for the current intent.
40
+ - `requestable?`: returns true if the slot is active for the current
41
+ intent and it is not filled.
42
+
43
+ [1]: https://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html#lambda-response-recentIntentSummaryView
44
+
1
45
  # 2.0.0 - August 19, 2020
2
46
 
3
47
  * **breaking change:** Rename `Aws::Lex::Conversation::Type::CurrentIntent` to `Aws::Lex::Conversation::Type::Intent`.
@@ -11,10 +11,12 @@ module Aws
11
11
  fulfillment_state = options.fetch(:fulfillment_state) { Type::FulfillmentState.new('Fulfilled') }
12
12
  conversation.close(
13
13
  fulfillment_state: fulfillment_state,
14
- message: Type::Message.new(
15
- content: content,
16
- content_type: content_type
17
- )
14
+ messages: [
15
+ Type::Message.new(
16
+ content: content,
17
+ content_type: content_type
18
+ )
19
+ ]
18
20
  )
19
21
  end
20
22
  end
@@ -10,6 +10,8 @@ module Aws
10
10
  def initialize(opts = {})
11
11
  super
12
12
  session_state.dialog_action = dialog_action
13
+ # by default, we set intent as nil unless overridden
14
+ session_state.intent = opts[:intent]
13
15
  end
14
16
 
15
17
  def dialog_action
@@ -29,13 +29,17 @@ module Aws
29
29
  slot_to_elicit: name,
30
30
  messages: [
31
31
  {
32
- contentType: content_type,
32
+ contentType: message_content_type,
33
33
  content: elicitation_content
34
34
  }
35
35
  ]
36
36
  )
37
37
  end
38
38
 
39
+ def message_content_type
40
+ content_type.is_a?(Proc) ? content_type.call(conversation) : content_type
41
+ end
42
+
39
43
  def elicit?
40
44
  elicit.call(conversation) && !slot.filled?
41
45
  end
@@ -26,10 +26,11 @@ module Aws
26
26
  end
27
27
 
28
28
  def to_lex
29
- self.class.attributes.each_with_object({}) do |attribute, hash|
29
+ output = self.class.attributes.each_with_object({}) do |attribute, hash|
30
30
  value = transform_to_lex(public_send(attribute))
31
31
  hash[self.class.mapping.fetch(attribute)] = value
32
32
  end
33
+ output.compact
33
34
  end
34
35
 
35
36
  private
@@ -40,9 +41,10 @@ module Aws
40
41
  if value.respond_to?(:to_lex)
41
42
  value.to_lex
42
43
  else
43
- value.each_with_object({}) do |(key, val), hash|
44
+ output = value.each_with_object({}) do |(key, val), hash|
44
45
  hash[key.to_sym] = transform_to_lex(val)
45
46
  end
47
+ output.compact
46
48
  end
47
49
  when Array
48
50
  value.map { |v| transform_to_lex(v) }
@@ -66,7 +68,7 @@ module Aws
66
68
  end
67
69
 
68
70
  def symbolize_hash!
69
- ->(v) { v.deep_transform_keys(&:to_sym) }
71
+ ->(v) { v.transform_keys(&:to_sym) }
70
72
  end
71
73
 
72
74
  def computed_property(attribute, callable)
@@ -9,7 +9,7 @@ module Aws
9
9
 
10
10
  required :bot
11
11
  required :input_mode
12
- required :input_transcript
12
+ required :input_transcript, default: -> { '' }
13
13
  required :interpretations
14
14
  required :invocation_source
15
15
  required :message_version
@@ -9,6 +9,8 @@ module Aws
9
9
 
10
10
  enumeration('Fulfilled')
11
11
  enumeration('Failed')
12
+ enumeration('InProgress')
13
+ enumeration('ReadyForFulfillment')
12
14
  end
13
15
  end
14
16
  end
@@ -22,13 +22,13 @@ module Aws
22
22
  end
23
23
 
24
24
  instance.raw_slots.each_with_object(default_hash) do |(key, value), hash|
25
- value ||= { shape: 'Scalar' }
25
+ normalized = value&.transform_keys(&:to_sym) || { shape: 'Scalar' }
26
26
  hash[key.to_sym] = Slot.shrink_wrap(
27
27
  active: true,
28
28
  name: key,
29
- shape: value[:shape],
30
- value: value[:value],
31
- values: value[:values]
29
+ shape: normalized[:shape],
30
+ value: normalized[:value],
31
+ values: normalized[:values]
32
32
  )
33
33
  end
34
34
  end
@@ -10,12 +10,10 @@ module Aws
10
10
  optional :checkpoints
11
11
 
12
12
  def checkpoints
13
- @checkpoints ||= begin # rubocop:disable Style/RedundantBegin
14
- JSON.parse(
15
- Base64.urlsafe_decode64(fetch(:checkpoints) { Base64.urlsafe_encode64([].to_json, padding: false) })
16
- ).map do |checkpoint|
17
- Checkpoint.shrink_wrap(checkpoint)
18
- end
13
+ @checkpoints ||= JSON.parse(
14
+ Base64.urlsafe_decode64(fetch(:checkpoints) { Base64.urlsafe_encode64([].to_json, padding: false) })
15
+ ).map do |checkpoint|
16
+ Checkpoint.shrink_wrap(checkpoint)
19
17
  end
20
18
  end
21
19
 
@@ -16,7 +16,7 @@ module Aws
16
16
  active_contexts: Array[Context],
17
17
  dialog_action: DialogAction,
18
18
  intent: Intent,
19
- session_attributes: ->(v) { SessionAttributes[v.deep_symbolize_keys] }
19
+ session_attributes: ->(v) { SessionAttributes[v.transform_keys(&:to_sym)] }
20
20
  )
21
21
  end
22
22
  end
@@ -14,6 +14,14 @@ module Aws
14
14
  alias_method :value, :interpreted_value
15
15
  alias_method :value=, :interpreted_value=
16
16
 
17
+ def to_lex
18
+ {
19
+ interpretedValue: interpreted_value,
20
+ originalValue: original_value,
21
+ resolvedValues: resolved_values
22
+ }
23
+ end
24
+
17
25
  def resolve!(index: 0)
18
26
  self.interpreted_value = resolved(index: index)
19
27
  end
@@ -3,7 +3,7 @@
3
3
  module Aws
4
4
  module Lex
5
5
  class Conversation
6
- VERSION = '4.0.0'
6
+ VERSION = '4.2.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-lex-conversation
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Doyle
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2021-07-14 00:00:00.000000000 Z
15
+ date: 2021-08-23 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: shrink_wrap