ecoportal-api-graphql 1.3.3 → 1.3.4

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: e148fcd6c75c8724f75b4797859146f245d9809a7e0c14330e70b0f0eeaecbbe
4
- data.tar.gz: 819b4b7a1c61ad24a186688d45dc1a094dc7e09ea5b13b520837fa8fd0913b2e
3
+ metadata.gz: 5cc6136dc79d157acebf842f4b451e86a0f0266a5d239ad11dfa1f1db2f27ae7
4
+ data.tar.gz: 0a484624cc89b965ecb36e33beeb24470041288167deb2d48f52933a2f5f1d46
5
5
  SHA512:
6
- metadata.gz: d51e9a2180bab176ec59881c3a4f0096254c668d81cf7e728ae3cba97b6c6eab0804a94947894f1eb0f5d00b4e4aeefa51feb9fa486a02a1694891d67819c5c7
7
- data.tar.gz: 6ffde82c2a3bd6434dd93e3ed305fa9d0c36af846aa4b4556ab47409fe032a56a27d4d7e8632c61772bd271e7c956a7712660ae5719c4c65341132ce25c482b7
6
+ metadata.gz: aa8a69f025ff59c272b9b4285d76740d680e4a1757936ccc88383b9cda0335b1142842469cce72a330bc58bec970ca29ef1151b88761407f7938feeb4dbed220
7
+ data.tar.gz: 5da6da6b51a4795ba03f148a7b50d73f2465aa1c424be3f5accaebcd8eae3e599c022132458eabc0448d66df31f990d9f66b8efb5886b51bdbb061351afda4e5
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [1.3.4] - 2025-08-xx
5
+ ## [1.3.5] - 2025-09-xx
6
6
 
7
7
  ### Added
8
8
 
@@ -10,6 +10,27 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
+ ## [1.3.4] - 2025-09-04
14
+
15
+ ### Added
16
+
17
+ - Command execution result: **added** command doc when there's a `results` error.
18
+ - Payload improvements:
19
+ - On `LocationsError.validationErrors`: fetch `property` property.
20
+ - On **results**, `Command` always fetch `__typename` and the other properties.
21
+
22
+ ### Changed
23
+
24
+ - Changed base `error_doc`: **consistent property name**
25
+
26
+ ### Fixed
27
+
28
+ - Correct fetch on `ok` (sometimes it is `null`: that doesn't mean failed).
29
+ - **Consistent order** on `error?` and `error_doc`.
30
+ - `Draft`
31
+ - **Overlapping** name `ConflictingIds` (vs `LocationsError.conflictingIds`)
32
+ - **Wrong** include on `FetchNested`
33
+
13
34
  ## [1.3.3] - 2025-08-29
14
35
 
15
36
  ### Added
@@ -11,46 +11,50 @@ module Ecoportal
11
11
  passkey :id
12
12
 
13
13
  passthrough :name, :notes
14
- passboolean :commited, :ok
14
+
15
+ passboolean :commited
15
16
  alias_method :commited?, :commited
16
- alias_method :ok?, :ok
17
17
 
18
18
  embeds_one :createdAt, klass: Base::DateTime
19
19
 
20
+ embeds_one :structure, klass: :structure_class
21
+
20
22
  passarray :conflictingIds
21
23
  embeds_many :commands, klass: Interface::LocationStructure::Command
22
24
  embeds_many :results, read_only: true, klass: "Ecoportal::API::GraphQL::Payload::LocationStructure::CommandExecutionResult"
23
25
 
24
- embeds_one :structure, klass: :structure_class
26
+ passboolean :ok
25
27
 
26
- include Error::LocationsError::FetchNested
28
+ def ok?
29
+ ok != false
30
+ end
31
+
32
+ def success?
33
+ !error?
34
+ end
27
35
 
28
36
  def error?
29
- !ok? ||
37
+ conflictingIds? ||
30
38
  result_errors? ||
31
- conflictingIds?
39
+ !ok?
32
40
  end
33
41
 
34
42
  def error_doc
35
- if result_errors?
43
+ if conflictingIds?
36
44
  {
37
- results: [result_errors.first&.error_doc]
45
+ conflictingIds: conflictingIds.doc
38
46
  }
39
- elsif conflictingIds?
47
+ elsif result_errors?
40
48
  {
41
- conflictingIds: conflictingIds.doc
49
+ results: [result_errors.first&.error_doc]
42
50
  }
43
51
  elsif !ok?
44
52
  {
45
- ok: false
53
+ ok: ok
46
54
  }
47
55
  end
48
56
  end
49
57
 
50
- def success?
51
- !error?
52
- end
53
-
54
58
  def structure_id
55
59
  parent_structure&.id
56
60
  end
@@ -68,6 +72,10 @@ module Ecoportal
68
72
  _parent._parent
69
73
  end
70
74
 
75
+ def conflictingIds?
76
+ (conflictingIds || []).any?
77
+ end
78
+
71
79
  def result_errors?
72
80
  result_errors.any?
73
81
  end
@@ -75,10 +83,6 @@ module Ecoportal
75
83
  def result_errors
76
84
  results.select(&:error?)
77
85
  end
78
-
79
- def conflictingIds?
80
- (conflictingIds || []).any?
81
- end
82
86
  end
83
87
  end
84
88
  end # GraphQL
@@ -7,9 +7,9 @@ module Ecoportal
7
7
  def locations_error_doc
8
8
  return unless locations_error?
9
9
 
10
- if conflictingIds?
10
+ if loc_err_conflicting_ids?
11
11
  {
12
- conflictingIds: conflictingIds.doc
12
+ conflictingIds: loc_err_conflicting_ids.doc
13
13
  }
14
14
  elsif validationErrors?
15
15
  {
@@ -19,18 +19,20 @@ module Ecoportal
19
19
  end
20
20
 
21
21
  def locations_error?
22
- !error.nil? && !error.empty?
22
+ return false if error.nil?
23
+
24
+ !error.empty?
23
25
  end
24
26
 
25
- def conflictingIds?
26
- conflictingIds.any?
27
+ def loc_err_conflicting_ids?
28
+ loc_err_conflicting_ids.any?
27
29
  end
28
30
 
29
31
  def validationErrors?
30
32
  validationErrors.any?
31
33
  end
32
34
 
33
- def conflictingIds
35
+ def loc_err_conflicting_ids
34
36
  return [] unless (err = error)
35
37
 
36
38
  err.conflictingIds || []
@@ -10,7 +10,9 @@ module Ecoportal
10
10
  embeds_many :validationErrors, klass: LocationsValidationError
11
11
 
12
12
  def empty?
13
- conflictingIds.empty? && validationErrors.empty?
13
+ return false unless conflictingIds.empty?
14
+
15
+ validationErrors.empty?
14
16
  end
15
17
 
16
18
  def any?
@@ -8,7 +8,10 @@ module Ecoportal
8
8
  passthrough :error, :message, :property
9
9
 
10
10
  def empty?
11
- error.nil? && message.nil? && property.nil?
11
+ return false unless error.nil?
12
+ return false unless message.nil?
13
+
14
+ property.nil?
12
15
  end
13
16
  end
14
17
  end
@@ -17,11 +17,24 @@ module Ecoportal
17
17
  id
18
18
  state
19
19
  __typename
20
+ ... on LocationInsertCommand {
21
+ nodeId name parentId insertBefore classificationIds
22
+ }
23
+ ... on LocationUpdateCommand {
24
+ nodeId newId
25
+ newName: name
26
+ newClassificationIds: classificationIds
27
+ }
28
+ ... on LocationArchiveCommand { nodeId }
29
+ ... on LocationUnarchiveCommand { nodeId }
30
+ ... on LocationMoveCommand { nodeId parentId insertBefore }
31
+ ... on LocationReorderCommand { parentId orderedIds }
20
32
  }
21
33
  error {
22
34
  message
23
35
  conflictingIds
24
36
  validationErrors {
37
+ property
25
38
  error
26
39
  message
27
40
  }
@@ -30,6 +43,7 @@ module Ecoportal
30
43
  commands {
31
44
  id
32
45
  state
46
+ __typename
33
47
  }
34
48
  }
35
49
  GRAPHQL
@@ -7,6 +7,7 @@ module Ecoportal
7
7
  message
8
8
  conflictingIds
9
9
  validationErrors {
10
+ property
10
11
  error
11
12
  message
12
13
  }
@@ -5,7 +5,20 @@ module Ecoportal
5
5
  module LocationStructure
6
6
  class UpdateCommand < Interface::LocationStructure::Command
7
7
  passthrough :nodeId, :newId
8
- passthrough :name, :classificationIds
8
+ passthrough :name, :newName
9
+ passthrough :classificationIds, :newClassificationIds
10
+
11
+ def name
12
+ super if newName.nil?
13
+
14
+ newName
15
+ end
16
+
17
+ def classificationIds
18
+ super if newClassificationIds.empty?
19
+
20
+ newClassificationIds
21
+ end
9
22
  end
10
23
  end
11
24
  end
@@ -18,19 +18,21 @@ module Ecoportal
18
18
  embeds_one :item, klass: :item_class
19
19
  embeds_one :errors, klass: Error::ValidationErrors, nullable: true
20
20
 
21
- def error?
22
- errors && !errors.empty?
23
- end
24
-
25
21
  def success?
26
22
  !error?
27
23
  end
28
24
 
25
+ def error?
26
+ return false if errors.nil?
27
+
28
+ !errors.empty?
29
+ end
30
+
29
31
  def error_doc
30
32
  return unless (err_doc = errors&.doc)
31
33
 
32
34
  {
33
- validationErrors: err_doc
35
+ errors: err_doc
34
36
  }
35
37
  end
36
38
  end
@@ -8,11 +8,12 @@ module Ecoportal
8
8
 
9
9
  passthrough :clientMutationId
10
10
  embeds_one :structure, klass: Model::LocationStructure
11
- embeds_one :error, klass: Error::LocationsError, nullable: true
12
- embeds_many :results, read_only: true, klass: Payload::LocationStructure::CommandExecutionResult
13
11
 
12
+ embeds_one :error, klass: Error::LocationsError, nullable: true
14
13
  include Error::LocationsError::FetchNested
15
14
 
15
+ embeds_many :results, read_only: true, klass: Payload::LocationStructure::CommandExecutionResult
16
+
16
17
  def error?
17
18
  super || result_errors? || locations_error?
18
19
  end
@@ -7,14 +7,23 @@ module Ecoportal
7
7
  read_only!
8
8
 
9
9
  embeds_one :command, klass: Interface::LocationStructure::Command
10
- embeds_one :error, nullable: true, klass: Error::LocationsError
11
- passboolean :ok
12
- alias_method :ok?, :ok
13
10
 
11
+ embeds_one :error, klass: Error::LocationsError, nullable: true
14
12
  include Error::LocationsError::FetchNested
15
13
 
14
+ passboolean :ok
15
+
16
+ def ok?
17
+ ok != false
18
+ end
19
+
20
+ def success?
21
+ !error?
22
+ end
23
+
16
24
  def error?
17
- !ok? || locations_error?
25
+ locations_error? ||
26
+ !ok?
18
27
  end
19
28
 
20
29
  def error_doc
@@ -24,13 +33,14 @@ module Ecoportal
24
33
  }
25
34
  elsif !ok?
26
35
  {
27
- ok: false
36
+ ok: ok
28
37
  }
29
- end
30
- end
38
+ end.tap do |err_doc|
39
+ next unless err_doc.is_a?(Hash)
40
+ next if err_doc.empty?
31
41
 
32
- def success?
33
- !error?
42
+ err_doc[:command] = command.doc
43
+ end
34
44
  end
35
45
  end
36
46
  end
@@ -6,7 +6,10 @@ module Ecoportal
6
6
  module Draft
7
7
  class AddCommands < Create
8
8
  passboolean :ok
9
- alias_method :ok?, :ok
9
+
10
+ def ok?
11
+ ok != false
12
+ end
10
13
 
11
14
  def error?
12
15
  super || !ok?
@@ -16,7 +19,7 @@ module Ecoportal
16
19
  err_doc = super
17
20
  return err_doc if err_doc
18
21
 
19
- { ok: false } unless ok?
22
+ { ok: ok } unless ok?
20
23
  end
21
24
  end
22
25
  end
@@ -6,7 +6,10 @@ module Ecoportal
6
6
  module Draft
7
7
  class Delete < Logic::Payload
8
8
  passboolean :ok
9
- alias_method :ok?, :ok
9
+
10
+ def ok?
11
+ ok != false
12
+ end
10
13
 
11
14
  def error?
12
15
  super || !ok?
@@ -16,7 +19,7 @@ module Ecoportal
16
19
  err_doc = super
17
20
  return err_doc if err_doc
18
21
 
19
- { ok: false } unless ok?
22
+ { ok: ok } unless ok?
20
23
  end
21
24
  end
22
25
  end
@@ -5,17 +5,19 @@ module Ecoportal
5
5
  module LocationStructure
6
6
  module Draft
7
7
  class DropBadCommands < AddCommands
8
- passboolean :ok
9
- alias_method :ok?, :ok
10
-
11
8
  embeds_one :error, klass: Error::LocationsError, nullable: true
12
-
13
9
  include Error::LocationsError::FetchNested
14
10
 
11
+ passboolean :ok
12
+
13
+ def ok?
14
+ ok != false
15
+ end
16
+
15
17
  def error?
16
18
  super ||
17
- !ok? ||
18
- locations_error?
19
+ locations_error? ||
20
+ !ok?
19
21
  end
20
22
 
21
23
  def error_doc
@@ -28,7 +30,7 @@ module Ecoportal
28
30
  }
29
31
  elsif !ok?
30
32
  {
31
- ok: false
33
+ ok: ok
32
34
  }
33
35
  end
34
36
  end
@@ -10,19 +10,22 @@ module Ecoportal
10
10
  embeds_one :structure, klass: :item_class
11
11
  alias_method :item, :structure
12
12
 
13
- passboolean :ok
14
- alias_method :ok?, :ok
15
-
16
13
  embeds_one :error, klass: Error::LocationsError, nullable: true
14
+ include Error::LocationsError::FetchNested
15
+
17
16
  embeds_many :results, read_only: true, klass: Payload::LocationStructure::CommandExecutionResult
18
17
 
19
- include Error::LocationsError::FetchNested
18
+ passboolean :ok
19
+
20
+ def ok?
21
+ ok != false
22
+ end
20
23
 
21
24
  def error?
22
25
  super ||
23
- !ok? ||
24
26
  locations_error? ||
25
- result_errors?
27
+ result_errors? ||
28
+ !ok?
26
29
  end
27
30
 
28
31
  def error_doc
@@ -37,6 +40,10 @@ module Ecoportal
37
40
  {
38
41
  results: [result_errors.first&.error_doc]
39
42
  }
43
+ elsif !ok?
44
+ {
45
+ ok: ok
46
+ }
40
47
  end
41
48
  end
42
49
 
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GRAPQL_VERSION = '1.3.3'.freeze
3
+ GRAPQL_VERSION = '1.3.4'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-28 00:00:00.000000000 Z
11
+ date: 2025-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry