decidim-api 0.28.2 → 0.29.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfc163b3464d9c6c0e338f0696ed973109f91ecc3afe8a69102521517b1fda36
4
- data.tar.gz: cf99822454e41597390c2df809bc5976d54b0a2e5de7aca957acf8a97b7f6db9
3
+ metadata.gz: a4f9bdaae8d166f02a55ec472fe0e400d2046f6cb38713381466c572e5f17c5b
4
+ data.tar.gz: 1b0c10c1c0e0ef7c8661465ace0d185d914173475bf33f6ec6fcb04f03bf626e
5
5
  SHA512:
6
- metadata.gz: 1c8536ee5c6ea50a30cbd1a66805b5988729b20f1872e5d845099a565e32a30120ee2c5e8e29bef8c7c391c1d56e1cade748885d738d94358ea16903361495ab
7
- data.tar.gz: 216ed5e3f45b3812ca21dcf8ebdf83521bf5e61196f00d4cc53387e433367eef35ff691750cbbf59b5f330ec57f4de52d40fc063cdc57630a9f0aee526bb6369
6
+ metadata.gz: 57da850dc9496e413f1c7c033a51bedb4258414a426bada0e4f41b986ed1cca6d06fc6b5b5f0707f0eaf854b5c802590c3107564fbd79eff04db9fb16873aed4
7
+ data.tar.gz: 2293c845d89f6ffc9662e67edccf170ae02e4639915b18df8b8cda8441bf9e4375551ee2b492df36be26a97b8b4f7d6ec863a7e5294937c1442cae3215a630ac
@@ -59,8 +59,7 @@ em {
59
59
  bottom: 0;
60
60
  width: 250px;
61
61
  padding: 0;
62
- overflow-x: hidden;
63
- overflow-y: scroll;
62
+ overflow: hidden scroll;
64
63
  -webkit-overflow-scrolling: touch;
65
64
  -ms-overflow-style: none;
66
65
  border-right: 1px solid #eee;
@@ -1,85 +1,100 @@
1
- /* eslint-disable require-jsdoc */
1
+ /* eslint-disable require-jsdoc, react/no-deprecated */
2
2
 
3
3
  import "entrypoints/decidim_api_graphiql.scss";
4
4
  // Styles from node_modules/graphiql/graphiql.css
5
5
  // It needs to be done in JS because postcss-import does not find files in node_modules/
6
- import "graphiql/graphiql.css"
6
+ import "graphiql/graphiql.css";
7
7
 
8
8
  import React from "react";
9
- import ReactDOM from "react-dom";
9
+ import { createRoot } from "react-dom/client";
10
10
 
11
- import GraphiQL from "graphiql";
12
- import Configuration from "src/decidim/configuration"
11
+ import { GraphiQL } from "graphiql"; // eslint-disable-line no-unused-vars
12
+ import Configuration from "src/decidim/configuration";
13
13
 
14
14
  window.Decidim = window.Decidim || {};
15
- window.Decidim.config = new Configuration()
15
+ window.Decidim.config = new Configuration();
16
16
 
17
17
  let parameters = {};
18
18
 
19
19
  // Parse the search string to get url parameters.
20
20
  const search = window.location.search;
21
- search.substr(1).split("&").forEach(function (entry) {
22
- let eq = entry.indexOf("=");
23
- if (eq >= 0) {
24
- parameters[decodeURIComponent(entry.slice(0, eq))] =
25
- decodeURIComponent(entry.slice(eq + 1));
26
- }
27
- });
21
+ search.
22
+ substr(1).
23
+ split("&").
24
+ forEach(function (entry) {
25
+ let eq = entry.indexOf("=");
26
+ if (eq >= 0) {
27
+ parameters[decodeURIComponent(entry.slice(0, eq))] = decodeURIComponent(
28
+ entry.slice(eq + 1)
29
+ );
30
+ }
31
+ });
28
32
  // if variables was provided, try to format it.
29
33
  if (parameters.variables) {
30
34
  try {
31
- parameters.variables =
32
- JSON.stringify(JSON.parse(parameters.variables), null, 2);
35
+ parameters.variables = JSON.stringify(
36
+ JSON.parse(parameters.variables),
37
+ null,
38
+ 2
39
+ );
33
40
  } catch (error) {
34
41
  // Do nothing, we want to display the invalid JSON as a string, rather
35
42
  // than present an error.
36
43
  }
37
44
  }
38
45
 
39
- const updateURL = function() {
40
- const newSearch = Object.keys(parameters).map(function (key) {
41
- return `${encodeURIComponent(key)}=${encodeURIComponent(parameters[key])}`;
42
- }).join("&");
46
+ const updateURL = function () {
47
+ const newSearch = Object.keys(parameters).
48
+ map(function (key) {
49
+ return `${encodeURIComponent(
50
+ key
51
+ )}=${encodeURIComponent(parameters[key])}`;
52
+ }).
53
+ join("&");
43
54
 
44
55
  history.replaceState(null, null, `?${newSearch}`);
45
- }
56
+ };
46
57
 
47
58
  // When the query and variables string is edited, update the URL bar so
48
59
  // that it can be easily shared
49
- const onEditQuery = function(newQuery) {
60
+ const onEditQuery = function (newQuery) {
50
61
  parameters.query = newQuery;
51
62
  updateURL();
52
- }
63
+ };
53
64
 
54
- const onEditVariables = function(newVariables) {
65
+ const onEditVariables = function (newVariables) {
55
66
  parameters.variables = newVariables;
56
67
  updateURL();
57
- }
68
+ };
58
69
 
59
70
  // Defines a GraphQL fetcher using the fetch API.
60
- const graphQLFetcher = function(graphQLParams) {
71
+ const graphQLFetcher = function (graphQLParams) {
61
72
  const graphQLEndpoint = window.Decidim.config.get("graphql_endpoint");
62
73
  return fetch(graphQLEndpoint, {
63
74
  method: "post",
64
75
  headers: JSON.parse(window.Decidim.config.get("request_headers")),
65
76
  body: JSON.stringify(graphQLParams),
66
77
  credentials: "include"
67
- }).then(function(response) {
78
+ }).then(function (response) {
68
79
  try {
69
80
  return response.json();
70
81
  } catch (error) {
71
82
  return {
72
- "status": response.status,
73
- "message": "The server responded with invalid JSON, this is probably a server-side error",
74
- "response": response.text()
83
+ status: response.status,
84
+ message:
85
+ "The server responded with invalid JSON, this is probably a server-side error",
86
+ response: response.text()
75
87
  };
76
88
  }
77
- })
78
- }
89
+ });
90
+ };
79
91
 
80
92
  window.addEventListener("DOMContentLoaded", () => {
81
- // Render <GraphiQL /> into the body.
82
- ReactDOM.render(
93
+ const container = document.getElementById("graphiql-container");
94
+
95
+ const root = createRoot(container);
96
+
97
+ root.render(
83
98
  React.createElement(GraphiQL, {
84
99
  fetcher: graphQLFetcher,
85
100
  defaultQuery: window.Decidim.config.get("default_query"),
@@ -87,7 +102,6 @@ window.addEventListener("DOMContentLoaded", () => {
87
102
  variables: parameters.variables,
88
103
  onEditQuery: onEditQuery,
89
104
  onEditVariables: onEditVariables
90
- }),
91
- document.getElementById("graphiql-container")
92
- )
105
+ })
106
+ );
93
107
  });
@@ -1,7 +1,7 @@
1
1
  <div class="content">
2
2
  <div class="version">Decidim <%= Decidim.version %></div>
3
3
 
4
- <h1><%= current_organization.name %> API documentation</h1>
4
+ <h1><%= current_organization_name %> API documentation</h1>
5
5
  <% if defined?(graphiql_path) %>
6
6
  <%= link_to "Explore the API interactively with GraphiQL", graphiql_path %>
7
7
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <html>
2
2
  <head>
3
- <title><%= current_organization.name %> - API Documentation</title>
3
+ <title><%= current_organization_name %> - API Documentation</title>
4
4
  <%= stylesheet_pack_tag("decidim_api_docs") %>
5
5
  </head>
6
6
  <body>
data/config/routes.rb CHANGED
@@ -5,5 +5,5 @@ Decidim::Api::Engine.routes.draw do
5
5
  get "/docs", to: "documentation#show", as: :documentation
6
6
  get "/docs/*path", to: "documentation#show"
7
7
  get "/", to: redirect("/api/docs")
8
- post "/" => "queries#create", as: :root
8
+ post "/" => "queries#create", :as => :root
9
9
  end
data/decidim-api.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  "homepage_uri" => "https://decidim.org",
20
20
  "source_code_uri" => "https://github.com/decidim/decidim"
21
21
  }
22
- s.required_ruby_version = "~> 3.1.0"
22
+ s.required_ruby_version = "~> 3.2.0"
23
23
 
24
24
  s.name = "decidim-api"
25
25
  s.summary = "Decidim API module"
@@ -32,11 +32,9 @@ Gem::Specification.new do |s|
32
32
  end
33
33
  end
34
34
 
35
- s.add_dependency "commonmarker", "~> 0.23.0", ">= 0.23.9"
36
35
  s.add_dependency "decidim-core", Decidim::Api.version
37
- # Graphql version 2.1 breaks graphql-client compatibility See https://github.com/github/graphql-client/pull/310
38
- s.add_dependency "graphql", "~> 2.0.0"
39
- s.add_dependency "graphql-docs", "~> 3.0.1"
36
+ s.add_dependency "graphql", "~> 2.2.6"
37
+ s.add_dependency "graphql-docs", "~> 4.0"
40
38
  s.add_dependency "rack-cors", "~> 1.0"
41
39
 
42
40
  s.add_development_dependency "decidim-comments", Decidim::Api.version
@@ -7,7 +7,7 @@ module Decidim
7
7
  # @example Adding a header to the request
8
8
  # config.headers["My-Header"] = -> (view_context) { "My-Value" }
9
9
  #
10
- # @return [Hash<String => Proc>] Keys are headers to include in GraphQL requests, values are `->(view_context) { ... }` procs to determin values
10
+ # @return [Hash<String => Proc>] Keys are headers to include in GraphQL requests, values are `->(view_context) { ... }` procs to determine values
11
11
  attr_accessor :headers
12
12
 
13
13
  attr_accessor :query_params, :initial_query, :csrf, :title, :logo
@@ -16,13 +16,12 @@ shared_examples "implements stats type" do
16
16
  { "name" => "results_count", "value" => 0 },
17
17
  { "name" => "debates_count", "value" => 0 },
18
18
  { "name" => "sortitions_count", "value" => 0 },
19
- { "name" => "posts_count", "value" => 0 },
20
- { "name" => "elections_count", "value" => 0 }
19
+ { "name" => "posts_count", "value" => 0 }
21
20
  ]
22
21
  }
23
22
  end
24
23
 
25
- it "executes sucessfully" do
24
+ it "executes successfully" do
26
25
  expect { response }.not_to raise_error
27
26
  end
28
27
 
@@ -3,6 +3,7 @@
3
3
  shared_context "with a graphql class type" do
4
4
  let!(:current_organization) { create(:organization) }
5
5
  let!(:current_user) { create(:user, organization: current_organization) }
6
+ let!(:current_component) { create(:component) }
6
7
  let(:model) { OpenStruct.new({}) }
7
8
  let(:type_class) { described_class }
8
9
  let(:variables) { {} }
@@ -26,7 +27,8 @@ shared_context "with a graphql class type" do
26
27
  root_value:,
27
28
  context: {
28
29
  current_organization:,
29
- current_user:
30
+ current_user:,
31
+ current_component:
30
32
  },
31
33
  variables:
32
34
  )
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-api version.
5
5
  module Api
6
6
  def self.version
7
- "0.28.2"
7
+ "0.29.0.rc1"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.2
4
+ version: 0.29.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -12,68 +12,48 @@ bindir: bin
12
12
  cert_chain: []
13
13
  date: 2024-07-16 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: commonmarker
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: 0.23.0
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 0.23.9
25
- type: :runtime
26
- prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- requirements:
29
- - - "~>"
30
- - !ruby/object:Gem::Version
31
- version: 0.23.0
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 0.23.9
35
15
  - !ruby/object:Gem::Dependency
36
16
  name: decidim-core
37
17
  requirement: !ruby/object:Gem::Requirement
38
18
  requirements:
39
19
  - - '='
40
20
  - !ruby/object:Gem::Version
41
- version: 0.28.2
21
+ version: 0.29.0.rc1
42
22
  type: :runtime
43
23
  prerelease: false
44
24
  version_requirements: !ruby/object:Gem::Requirement
45
25
  requirements:
46
26
  - - '='
47
27
  - !ruby/object:Gem::Version
48
- version: 0.28.2
28
+ version: 0.29.0.rc1
49
29
  - !ruby/object:Gem::Dependency
50
30
  name: graphql
51
31
  requirement: !ruby/object:Gem::Requirement
52
32
  requirements:
53
33
  - - "~>"
54
34
  - !ruby/object:Gem::Version
55
- version: 2.0.0
35
+ version: 2.2.6
56
36
  type: :runtime
57
37
  prerelease: false
58
38
  version_requirements: !ruby/object:Gem::Requirement
59
39
  requirements:
60
40
  - - "~>"
61
41
  - !ruby/object:Gem::Version
62
- version: 2.0.0
42
+ version: 2.2.6
63
43
  - !ruby/object:Gem::Dependency
64
44
  name: graphql-docs
65
45
  requirement: !ruby/object:Gem::Requirement
66
46
  requirements:
67
47
  - - "~>"
68
48
  - !ruby/object:Gem::Version
69
- version: 3.0.1
49
+ version: '4.0'
70
50
  type: :runtime
71
51
  prerelease: false
72
52
  version_requirements: !ruby/object:Gem::Requirement
73
53
  requirements:
74
54
  - - "~>"
75
55
  - !ruby/object:Gem::Version
76
- version: 3.0.1
56
+ version: '4.0'
77
57
  - !ruby/object:Gem::Dependency
78
58
  name: rack-cors
79
59
  requirement: !ruby/object:Gem::Requirement
@@ -94,42 +74,42 @@ dependencies:
94
74
  requirements:
95
75
  - - '='
96
76
  - !ruby/object:Gem::Version
97
- version: 0.28.2
77
+ version: 0.29.0.rc1
98
78
  type: :development
99
79
  prerelease: false
100
80
  version_requirements: !ruby/object:Gem::Requirement
101
81
  requirements:
102
82
  - - '='
103
83
  - !ruby/object:Gem::Version
104
- version: 0.28.2
84
+ version: 0.29.0.rc1
105
85
  - !ruby/object:Gem::Dependency
106
86
  name: decidim-dev
107
87
  requirement: !ruby/object:Gem::Requirement
108
88
  requirements:
109
89
  - - '='
110
90
  - !ruby/object:Gem::Version
111
- version: 0.28.2
91
+ version: 0.29.0.rc1
112
92
  type: :development
113
93
  prerelease: false
114
94
  version_requirements: !ruby/object:Gem::Requirement
115
95
  requirements:
116
96
  - - '='
117
97
  - !ruby/object:Gem::Version
118
- version: 0.28.2
98
+ version: 0.29.0.rc1
119
99
  - !ruby/object:Gem::Dependency
120
100
  name: decidim-participatory_processes
121
101
  requirement: !ruby/object:Gem::Requirement
122
102
  requirements:
123
103
  - - '='
124
104
  - !ruby/object:Gem::Version
125
- version: 0.28.2
105
+ version: 0.29.0.rc1
126
106
  type: :development
127
107
  prerelease: false
128
108
  version_requirements: !ruby/object:Gem::Requirement
129
109
  requirements:
130
110
  - - '='
131
111
  - !ruby/object:Gem::Version
132
- version: 0.28.2
112
+ version: 0.29.0.rc1
133
113
  description: API engine for decidim
134
114
  email:
135
115
  - josepjaume@gmail.com
@@ -197,14 +177,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
197
177
  requirements:
198
178
  - - "~>"
199
179
  - !ruby/object:Gem::Version
200
- version: 3.1.0
180
+ version: 3.2.0
201
181
  required_rubygems_version: !ruby/object:Gem::Requirement
202
182
  requirements:
203
- - - ">="
183
+ - - ">"
204
184
  - !ruby/object:Gem::Version
205
- version: '0'
185
+ version: 1.3.1
206
186
  requirements: []
207
- rubygems_version: 3.3.7
187
+ rubygems_version: 3.4.10
208
188
  signing_key:
209
189
  specification_version: 4
210
190
  summary: Decidim API module