audiences 1.5.3 → 1.5.4.alpha

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.
@@ -32,7 +32,7 @@ module Audiences
32
32
  end
33
33
 
34
34
  def signed_key
35
- to_sgid(for: SIGNED_GID_RESOURCE)
35
+ to_sgid(for: SIGNED_GID_RESOURCE).to_s
36
36
  end
37
37
  end
38
38
  end
@@ -10,11 +10,13 @@ module Audiences
10
10
  inverse_of: false
11
11
  end
12
12
 
13
- def self.fetch(external_ids)
13
+ def self.fetch(external_ids, count: 100)
14
14
  return [] unless external_ids.any?
15
15
 
16
- filter = Array(external_ids).map { "externalId eq #{_1}" }.join(" OR ")
17
- Audiences::Scim.resource(:Users).all(filter: filter)
16
+ Array(external_ids).in_groups_of(count, false).flat_map do |ids|
17
+ filter = Array(ids).map { "externalId eq #{_1}" }.join(" OR ")
18
+ Audiences::Scim.resource(:Users).all(count: count, filter: filter).to_a
19
+ end
18
20
  end
19
21
 
20
22
  def self.wrap(resources)
data/config/routes.rb CHANGED
@@ -1,19 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Audiences::Engine.routes.draw do
4
+ root "contexts#show"
5
+
4
6
  get "/scim(/*scim_path)" => "scim_proxy#get", as: :scim_proxy
5
7
  get "/:key" => "contexts#show", as: :signed_context
6
8
  get "/:key/users(/:criterion_id)" => "contexts#users", as: :users
7
9
  put "/:key" => "contexts#update"
8
10
  end
9
-
10
- Rails.application.routes.draw do
11
- direct :audience_context do |owner, relation = nil|
12
- context = Audiences::Context.for(owner, relation: relation)
13
- audiences.route_for(:signed_context, key: context.signed_key, **url_options)
14
- end
15
-
16
- direct :audience_scim_proxy do |options|
17
- audiences.route_for(:scim_proxy, **url_options, **options)
18
- end
19
- end
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Unreleased
2
2
 
3
+ # Version 1.5.4 (2024-12-19)
4
+
5
+ - Fix `authenticate` / `authentication` configuration [#481](https://github.com/powerhome/audiences/pull/481)
6
+ - Paginage user requests in audiences instead of SCIM [#507](https://github.com/powerhome/audiences/pull/507)
7
+
3
8
  # Version 1.5.3 (2024-12-19)
4
9
 
5
10
  - Rollback breaking change introduced by 1.5.1 [#479](https://github.com/powerhome/audiences/pull/479)
data/docs/README.md CHANGED
@@ -30,8 +30,8 @@ An audience is tied to an owning model within your application. In this document
30
30
 
31
31
  This can be done with an unobtrusive JS renderer like `react-rails` or a custom one as shown in [our dummy app](../audiences/spec/dummy/app/frontend/entrypoints/application.js). The editor requires two arguments:
32
32
 
33
- - The context URI: `audience_context_url(owner, relation)` helper
34
- - The SCIM endpoint: `audience_scim_proxy_url` helper if using the [proxy](#configuring-the-scim-proxy), or the SCIM endpoint directly.
33
+ - The audiences mount point: `audiences.root_url` URL helper
34
+ - The context signed key: I.e.: `owner.members_signed_key` or `Audiences::Context.for(owner, relation:).signed_key`
35
35
 
36
36
  ### Configuring Audiences
37
37
 
@@ -25,18 +25,18 @@ module Audiences
25
25
  # I.e.:
26
26
  #
27
27
  # Audiences.configure do |config|
28
- # config.authentication = ->(*) { authenticate_request }
28
+ # config.authenticate = ->(*) { authenticate_request }
29
29
  # end
30
30
  #
31
31
  # I.e:
32
32
  #
33
33
  # Audiences.configure do |config|
34
- # config.authentication = ->(request) do
34
+ # config.authenticate = ->(request) do
35
35
  # request.env["warden"].authenticate!
36
36
  # end
37
37
  # end
38
38
  #
39
- config_accessor :authentication do
39
+ config_accessor :authenticate do
40
40
  ->(*) { true }
41
41
  end
42
42
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Audiences
4
+ module EditorHelper
5
+ def render_audiences_editor(context, html_class: "audiences-editor",
6
+ uri: Audiences::Engine.routes.url_helpers.root_path)
7
+ content_tag(:div, "",
8
+ data: {
9
+ react_class: "AudiencesEditor",
10
+ audiences_uri: uri,
11
+ audiences_context: context.signed_key,
12
+ },
13
+ class: html_class)
14
+ end
15
+ end
16
+ end
@@ -10,6 +10,10 @@ module Audiences
10
10
  class Engine < ::Rails::Engine
11
11
  isolate_namespace Audiences
12
12
 
13
+ initializer "audiences.assets.precompile" do |app|
14
+ app.config.assets.precompile += %w[audiences-ujs.js] if app.config.respond_to?(:assets)
15
+ end
16
+
13
17
  initializer "audiences.model" do
14
18
  if Audiences.config.identity_class
15
19
  ActiveSupport.on_load(:active_record) do
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Audiences
4
+ class Railtie < Rails::Railtie
5
+ initializer "audiences.editor_helper" do
6
+ ActiveSupport.on_load(:action_view) do
7
+ require "audiences/editor_helper"
8
+ include Audiences::EditorHelper
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Audiences
4
- VERSION = "1.5.3"
4
+ VERSION = "1.5.4.alpha"
5
5
  end
data/lib/audiences.rb CHANGED
@@ -36,3 +36,4 @@ module_function
36
36
  end
37
37
 
38
38
  require "audiences/configuration"
39
+ require "audiences/railtie"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audiences
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-31 00:00:00.000000000 Z
10
+ date: 2025-03-18 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -33,6 +32,7 @@ extensions: []
33
32
  extra_rdoc_files: []
34
33
  files:
35
34
  - Rakefile
35
+ - app/assets/builds/audiences-ujs.js
36
36
  - app/controllers/audiences/application_controller.rb
37
37
  - app/controllers/audiences/contexts_controller.rb
38
38
  - app/controllers/audiences/scim_proxy_controller.rb
@@ -61,9 +61,11 @@ files:
61
61
  - docs/README.md
62
62
  - lib/audiences.rb
63
63
  - lib/audiences/configuration.rb
64
+ - lib/audiences/editor_helper.rb
64
65
  - lib/audiences/engine.rb
65
66
  - lib/audiences/model.rb
66
67
  - lib/audiences/notifications.rb
68
+ - lib/audiences/railtie.rb
67
69
  - lib/audiences/scim.rb
68
70
  - lib/audiences/scim/client.rb
69
71
  - lib/audiences/scim/resource.rb
@@ -78,7 +80,6 @@ metadata:
78
80
  source_code_uri: https://github.com/powerhome/audiences
79
81
  changelog_uri: https://github.com/powerhome/audiences/blob/main/packages/audiences/docs/CHANGELOG.md
80
82
  rubygems_mfa_required: 'true'
81
- post_install_message:
82
83
  rdoc_options: []
83
84
  require_paths:
84
85
  - lib
@@ -93,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
94
  - !ruby/object:Gem::Version
94
95
  version: '0'
95
96
  requirements: []
96
- rubygems_version: 3.5.23
97
- signing_key:
97
+ rubygems_version: 3.6.2
98
98
  specification_version: 4
99
99
  summary: Audiences system
100
100
  test_files: []