hub_kernel-api 0.6.0 → 0.7.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: 16098ba0ceb84acb8536551867732dae646869b478d18299bb85a6839d1db8e1
4
- data.tar.gz: 5b5b3d49bd804284796e8c7702b861b704c6e6ac77dba9a8e90b73f216845d52
3
+ metadata.gz: 012cd9631dd8925bcd3d6982acc076ee8ade6a159dbca527d3618ba4ff80eec4
4
+ data.tar.gz: 98850fb2e56aca0a182d1f70adc2deedb440e9b54f0f188e321a2738034d8991
5
5
  SHA512:
6
- metadata.gz: 816027b58264d0c192482819bd043cf28f14c3ec65c91043953c7fba75abdf21725c09db3809f65f506cdab7e89b04a556d7a225cce99da925e1c4b4726fbffc
7
- data.tar.gz: 2befb90df535ea4e2df15e8d229b058d46339bf730937dabb3e4511bc890abc0a1d2a1f945b6b38b15258453d7ea9c8ef57212685ff0a7f7e8e32038de40bfbb
6
+ metadata.gz: b2e7fc3101f127f70f515be313c0532efd5a64bce8f568dc693fa2e7e3a962dad5703ea5a295e3020cc56b644fc283854a140ac24d7f588d891227b30934bf70
7
+ data.tar.gz: 67b21cabf1dd75ad74c7c97a3d908432a7c508c5fd39b13a3108a63ede102b8864fc4dde26c47f6da666dbdd3234351e764a3d1d0f6431d4275fc94f7dbb12e9
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # hub_kernel-api
2
2
 
3
3
  Serves a hub_kernel hub's exposed methods as a JSON API. The host lists the hubs it
4
- serves, and every call goes through the host's own sign-in, then hub_kernel's permission
5
- check and account scope.
4
+ serves, and every call goes through the host's own sign-in, then the permission check and
5
+ account scope that hub_kernel-interface holds. It depends on hub_kernel-interface alone, not
6
+ on hub_kernel.
6
7
 
7
8
  ## Usage
8
9
 
@@ -26,8 +27,9 @@ exposes no methods, when two served hubs answer at the same address, or when a s
26
27
  hub's exposed list has a problem, naming each. Inside `to_prepare` it runs again after
27
28
  every code reload.
28
29
 
29
- The base controller's own sign-in runs before every call. hub_kernel's permission check
30
- and account scope must also be set, as hub_kernel's readme describes. Mount the engine:
30
+ The base controller's own sign-in runs before every call. The permission check and account
31
+ scope must also be set, `HubKernel::Authz.check` and `HubKernel::Context.scope`, as
32
+ hub_kernel-interface's readme describes. Mount the engine:
31
33
 
32
34
  ```ruby
33
35
  mount HubKernel::Api::Engine => "/api/v1/hubs"
@@ -1,5 +1,5 @@
1
1
  module HubKernel
2
2
  module Api
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- require "hub_kernel"
1
+ require "hub_kernel-interface"
2
2
  require "hub_kernel/api/version"
3
3
  require "hub_kernel/api/engine"
4
4
 
@@ -2,7 +2,7 @@
2
2
  name: hub_kernel-api-develop
3
3
  description: Use PROACTIVELY for calling a served hub over HTTP — listing the methods a caller may call at a hub's address, calling a read with GET, calling a write with POST, sending its values, and reading its answer or error status — MUST BE USED instead of hand-writing a controller or endpoint per hub method, or guessing at the API's responses.
4
4
  tools: Read, Write, Edit, Grep
5
- scope: hub JSON API — serving a hub_kernel hub's exposed methods as a JSON API in a host Rails app, each call behind the host's own sign-in and hub_kernel's permission check and account scope
5
+ scope: hub JSON API — serving a hub_kernel hub's exposed methods as a JSON API in a host Rails app, each call behind the host's own sign-in and hub_kernel-interface's permission check and account scope
6
6
  ---
7
7
 
8
8
  This local writes client code against the three endpoints below and follows the steps in
@@ -11,11 +11,11 @@ order. Where a step names a decision, it asks the developer and does not pick.
11
11
  ## What hub_kernel-api is
12
12
 
13
13
  A Rails engine that answers HTTP calls to the exposed methods of the hubs a host serves,
14
- each call made after the host's sign-in and checked and scoped by hub_kernel's permission
15
- check and account scope. Use this local when writing a front end, mobile app, service or
16
- request test that calls those methods, or when working out why a call answered as it did.
17
- Adding the gem, choosing the served hubs and mounting the engine belong to the install
18
- local.
14
+ each call made after the host's sign-in and checked and scoped by the permission check and
15
+ account scope that hub_kernel-interface holds. Use this local when writing a front end,
16
+ mobile app, service or request test that calls those methods, or when working out why a
17
+ call answered as it did. Adding the gem, choosing the served hubs and mounting the engine
18
+ belong to the install local.
19
19
 
20
20
  ## Interface
21
21
 
@@ -32,8 +32,7 @@ Every path is relative to the path the host mounted the engine at, such as
32
32
  ## How to use it
33
33
 
34
34
  1. Find the path the host mounted the API at in its `config/routes.rb`. Every URL
35
- below starts with it. If the API is not mounted,
36
- stop and use the install local.
35
+ below starts with it. If the API is not mounted, stop and use the install local.
37
36
 
38
37
  2. Find the hub's address. A hub answers at its module name underscored, so `Supplies`
39
38
  answers at `supplies`, unless the host listed it under a name of its own, such as
@@ -106,6 +105,6 @@ Every path is relative to the path the host mounted the engine at, such as
106
105
  - The account a call is made for comes from the host's sign-in, never from a value in the
107
106
  request.
108
107
  - Only the methods a hub exposes are reachable; adding a method to the API means exposing
109
- it on the hub in hub_kernel, not adding a route.
108
+ it on the hub, not adding a route.
110
109
  - Installing the gem, configuring it and choosing the served hubs are out of scope here;
111
110
  they belong to the install local.
@@ -2,7 +2,7 @@
2
2
  name: hub_kernel-api-info
3
3
  description: Use to learn what hub_kernel-api offers — serving a hub's exposed methods as a JSON API, the served hubs and their addresses, reads and writes, and how sign-in, permission and account scope apply to each call.
4
4
  tools: Read
5
- scope: hub JSON API — serving a hub_kernel hub's exposed methods as a JSON API in a host Rails app, each call behind the host's own sign-in and hub_kernel's permission check and account scope
5
+ scope: hub JSON API — serving a hub_kernel hub's exposed methods as a JSON API in a host Rails app, each call behind the host's own sign-in and hub_kernel-interface's permission check and account scope
6
6
  ---
7
7
 
8
8
  This local explains hub_kernel-api and makes no changes.
@@ -15,10 +15,13 @@ gem answers HTTP calls to their exposed methods and to a listing of them. It add
15
15
  business logic of its own: every answer is the return value of a method the hub
16
16
  already exposes.
17
17
 
18
+ It depends on hub_kernel-interface alone, not on hub_kernel. hub_kernel-interface
19
+ holds the permission check and the account scope, and the host sets both.
20
+
18
21
  Reach for it when a hub's exposed methods need to be called over HTTP, by a mobile
19
22
  app, another service or a front end, without writing a controller per method. Each
20
- call runs the host's own sign-in first, then hub_kernel's permission check and
21
- account scope, so the API never shows a caller more than the app itself would.
23
+ call runs the host's own sign-in first, then hub_kernel-interface's permission check
24
+ and account scope, so the API never shows a caller more than the app itself would.
22
25
 
23
26
  ## Interface
24
27
 
@@ -40,8 +43,8 @@ This local declares no commands. The surface is split between the other two loca
40
43
 
41
44
  ## Conventions
42
45
 
43
- - **Hub** — a hub_kernel module whose methods are declared as exposed. Only exposed
44
- methods are reachable; nothing else on the hub is.
46
+ - **Hub** — a module whose methods are declared as exposed through
47
+ hub_kernel-interface. Only exposed methods are reachable; nothing else on the hub is.
45
48
  - **Served hub** — a hub the host has listed for the API. A hub that is not served is
46
49
  answered as not found, as if it did not exist.
47
50
  - **Address** — the name a served hub answers at. By default it is the hub's module
@@ -2,7 +2,7 @@
2
2
  name: hub_kernel-api-install
3
3
  description: Use to hook hub_kernel-api into a project — adding the gem, naming the base controller and its person and account methods, listing the served hubs, running the startup check, and mounting the engine.
4
4
  tools: Bash, Read, Edit
5
- scope: hub JSON API — serving a hub_kernel hub's exposed methods as a JSON API in a host Rails app, each call behind the host's own sign-in and hub_kernel's permission check and account scope
5
+ scope: hub JSON API — serving a hub_kernel hub's exposed methods as a JSON API in a host Rails app, each call behind the host's own sign-in and hub_kernel-interface's permission check and account scope
6
6
  ---
7
7
 
8
8
  This local follows the steps below exactly and invents none. Where a step names a
@@ -10,12 +10,13 @@ decision, it asks the developer and does not pick.
10
10
 
11
11
  ## What hub_kernel-api is
12
12
 
13
- A Rails engine that serves the exposed methods of hub_kernel hubs as a JSON API; hook it
13
+ A Rails engine that serves the exposed methods of hub_kernel hubs as a JSON API. Hook it
14
14
  in when a Rails app needs its hubs callable over HTTP.
15
15
 
16
16
  ## Interface
17
17
 
18
- - `gem "hub_kernel-api"` — the Gemfile line that adds the gem; it brings hub_kernel with it.
18
+ - `gem "hub_kernel-api"` — the Gemfile line that adds the gem; it brings
19
+ hub_kernel-interface with it, and not hub_kernel.
19
20
  - `HubKernel::Api.base_controller=` — the name, as a String, of the host controller the
20
21
  API's controllers inherit from; defaults to `"ActionController::API"`.
21
22
  - `HubKernel::Api.person_method=` — the name, as a Symbol, of the method on the base
@@ -37,10 +38,11 @@ in when a Rails app needs its hubs callable over HTTP.
37
38
  gem "hub_kernel-api"
38
39
  ```
39
40
 
40
- 2. Confirm hub_kernel's permission check and account scope are already configured in
41
- the host. Every call is checked and scoped by them. If the host has a hub_kernel
42
- install local, use it for this; otherwise stop and ask the developer how they are
43
- set, and do not configure them from guesswork.
41
+ 2. Confirm the permission check and account scope that hub_kernel-interface holds are
42
+ already set in the host: `HubKernel::Authz.check` and `HubKernel::Context.scope`.
43
+ Every call is checked and scoped by them. If the host has a hub_kernel-interface
44
+ install local, use it for this. Otherwise stop and ask the developer how they are
45
+ set, and do not set them from guesswork.
44
46
 
45
47
  3. Ask the developer which controller the API inherits from. It must:
46
48
  - run the host's sign-in before every action, as a `before_action` that refuses an
@@ -56,8 +58,7 @@ in when a Rails app needs its hubs callable over HTTP.
56
58
  4. Ask the developer which hubs to serve and at what address each answers. A hub module
57
59
  answers at its module name underscored, so `Supplies` answers at `supplies`. To use a
58
60
  different address, the hub is listed as a one-pair Hash, `{ "money" => Billing::Ledger }`.
59
- Every listed hub must be a hub_kernel hub that exposes methods, and no two may share
60
- an address.
61
+ Every listed hub must expose methods, and no two may share an address.
61
62
 
62
63
  5. Create `config/initializers/hub_kernel_api.rb` with the answers from steps 3 and 4:
63
64
 
@@ -88,11 +89,11 @@ in when a Rails app needs its hubs callable over HTTP.
88
89
  7. Boot the app, for example with `bin/rails runner "puts :ok"`. A
89
90
  `HubKernel::Api::UnservableHubError` at boot names each problem:
90
91
  - `<Hub> exposes no methods to serve` — the entry is not a hub with exposed methods;
91
- remove it, or expose methods on it in hub_kernel.
92
+ remove it, or expose methods on it.
92
93
  - `<Hub> and <Hub> both answer at <address>` — give one of them its own address with
93
94
  a one-pair Hash.
94
- - Any other line is a problem with that hub's list of exposed methods, reported by
95
- hub_kernel; fix it in the hub.
95
+ - Any other line is a problem the hub reports with its own list of exposed methods;
96
+ fix it in the hub.
96
97
 
97
98
  ## Conventions
98
99
 
@@ -102,5 +103,7 @@ in when a Rails app needs its hubs callable over HTTP.
102
103
  - An edit to the initializer takes effect only after the server restarts.
103
104
  - Keep `HubKernel::Api.check!` in the initializer; without it a hub that cannot be served
104
105
  is found only when a client calls it.
106
+ - Setting the permission check and account scope is out of scope here; it belongs to
107
+ hub_kernel-interface.
105
108
  - Calling the API, its responses and its error statuses are out of scope here; they
106
109
  belong to the develop local.
@@ -1,4 +1,4 @@
1
- scope: hub JSON API — serving a hub_kernel hub's exposed methods as a JSON API in a host Rails app, each call behind the host's own sign-in and hub_kernel's permission check and account scope
1
+ scope: hub JSON API — serving a hub_kernel hub's exposed methods as a JSON API in a host Rails app, each call behind the host's own sign-in and hub_kernel-interface's permission check and account scope
2
2
 
3
3
  install:
4
4
  - gem "hub_kernel-api"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_kernel-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -24,19 +24,19 @@ dependencies:
24
24
  - !ruby/object:Gem::Version
25
25
  version: 8.1.3
26
26
  - !ruby/object:Gem::Dependency
27
- name: hub_kernel
27
+ name: hub_kernel-interface
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '0.18'
32
+ version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.18'
39
+ version: '0.3'
40
40
  description: 'hub_kernel-api gives any hub built on hub_kernel a JSON API: the host
41
41
  lists the hubs it serves, and every call goes through the host''s sign-in, permission
42
42
  check and account scope.'