haveapi-typescript-client 0.31.0 → 0.31.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 143493ba904e7309ec771812427d439bdc48543e4dd1196d6a5b5d6442305ff5
|
|
4
|
+
data.tar.gz: e3a9e2d444a80e95b646dfeee88e63ff01bb4bc7aacf03d0abfa3ef810a67644
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2515c9c47797f6d4b0da2e13c65773181d78480ad3b89480355242bbe91a1df1b2ea005d432300dd0d65274630e016fd455f80c8d89d826b4bc7bd49df3adcba
|
|
7
|
+
data.tar.gz: dbca4bc54f826c646cb798a37ced01c1ae7fba017df1d94aebc9d558386bc63df61c2f0102599dca8739203002c2a5264b78bf20cef8d4be4b60459cc9333c85
|
data/docs/documentation.md
CHANGED
|
@@ -84,6 +84,12 @@ description or saved snapshot. `resolve` returns a frozen canonical action;
|
|
|
84
84
|
`render` returns the server's code or limitation result. Rendering performs no
|
|
85
85
|
file, network, generator or compiler work.
|
|
86
86
|
|
|
87
|
+
Rendering selects the current action, authentication provider and metadata
|
|
88
|
+
namespace before recursively normalizing their contents. It leaves unrelated
|
|
89
|
+
description descendants untouched and keeps authorization decisions local to
|
|
90
|
+
each render. Deterministic work checks grow unrelated subtrees while keeping
|
|
91
|
+
the selected inputs and rendered source fixed.
|
|
92
|
+
|
|
87
93
|
Focused unit checks compile the actual rendered programs against generated
|
|
88
94
|
fixture modules with TypeScript 6, NodeNext/ES2022, `exactOptionalPropertyTypes`,
|
|
89
95
|
`noUncheckedIndexedAccess` and `verbatimModuleSyntax`. They cover aliases, nested
|
|
@@ -85,6 +85,11 @@ module HaveAPI::TypeScriptClient
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
# Match normalize's last-insertion key semantics without visiting descendants.
|
|
89
|
+
def normalized_members(value)
|
|
90
|
+
value.is_a?(Hash) ? value.to_h { |key, item| [key.to_s, item] } : {}
|
|
91
|
+
end
|
|
92
|
+
|
|
88
93
|
def index_resources(resources, parents)
|
|
89
94
|
resources.each do |resource|
|
|
90
95
|
accessors = (parents + [resource.fetch(:accessor_name)]).freeze
|
|
@@ -125,11 +130,12 @@ module HaveAPI::TypeScriptClient
|
|
|
125
130
|
end
|
|
126
131
|
|
|
127
132
|
def authentication(context, method, description = nil)
|
|
128
|
-
providers =
|
|
133
|
+
providers = normalized_members(normalized_members(context.description)['authentication'])
|
|
129
134
|
saved = @snapshot.fetch('description').fetch('authentication')
|
|
130
135
|
live = providers[method.to_s]
|
|
131
136
|
stored = saved[method.to_s]
|
|
132
137
|
unsupported! unless live.is_a?(Hash) && stored.is_a?(Hash)
|
|
138
|
+
live = normalize(live)
|
|
133
139
|
unsupported! if description && normalize(description) != live
|
|
134
140
|
case method.to_s
|
|
135
141
|
when 'basic'
|
|
@@ -145,7 +151,7 @@ module HaveAPI::TypeScriptClient
|
|
|
145
151
|
def action_authentication(action, context)
|
|
146
152
|
return [] unless action.fetch(:auth)
|
|
147
153
|
|
|
148
|
-
live =
|
|
154
|
+
live = normalized_members(normalized_members(context.description)['authentication'])
|
|
149
155
|
%w[basic token].each do |method|
|
|
150
156
|
next unless live.has_key?(method) && @snapshot.fetch('description').fetch('authentication').has_key?(method)
|
|
151
157
|
|
|
@@ -155,21 +161,21 @@ module HaveAPI::TypeScriptClient
|
|
|
155
161
|
end
|
|
156
162
|
|
|
157
163
|
def authorized_action(context)
|
|
158
|
-
|
|
159
|
-
resources = description['resources']
|
|
164
|
+
resources = normalized_members(context.description)['resources']
|
|
160
165
|
resource = nil
|
|
161
166
|
context.resource_path.each do |name|
|
|
162
|
-
resource = resources
|
|
167
|
+
resource = normalized_members(resources)[name.to_s]
|
|
163
168
|
return nil unless resource.is_a?(Hash)
|
|
164
169
|
|
|
165
|
-
resources = resource['resources']
|
|
170
|
+
resources = normalized_members(resource)['resources']
|
|
166
171
|
end
|
|
167
|
-
actions = resource
|
|
168
|
-
return
|
|
169
|
-
return actions[context.action_name.to_s] if actions.has_key?(context.action_name.to_s)
|
|
172
|
+
actions = normalized_members(normalized_members(resource)['actions'])
|
|
173
|
+
return normalize(actions[context.action_name.to_s]) if actions.has_key?(context.action_name.to_s)
|
|
170
174
|
|
|
171
|
-
aliases = actions.values.select
|
|
172
|
-
|
|
175
|
+
aliases = actions.values.select do |action|
|
|
176
|
+
Array(normalize(normalized_members(action)['aliases'])).include?(context.action_name.to_s)
|
|
177
|
+
end
|
|
178
|
+
normalize(aliases.first) if aliases.one?
|
|
173
179
|
end
|
|
174
180
|
|
|
175
181
|
def saved_action(action)
|
|
@@ -183,7 +189,8 @@ module HaveAPI::TypeScriptClient
|
|
|
183
189
|
expected_path = URI.parse(context.version_url.to_s).path.sub(%r{/+\z}, '') + action.fetch(:path_template)
|
|
184
190
|
unsupported! unless live['path'] == expected_path && live['method'] == action.fetch(:method) &&
|
|
185
191
|
(live['auth'] != false) == action.fetch(:auth) && (live['blocking'] == true) == action.fetch(:blocking)
|
|
186
|
-
|
|
192
|
+
namespace = normalized_members(normalized_members(context.description)['meta'])['namespace']
|
|
193
|
+
unsupported! unless normalize(namespace) == @ir.fetch(:metadata_namespace)
|
|
187
194
|
%w[input output].each do |direction|
|
|
188
195
|
left = saved[direction]
|
|
189
196
|
right = live[direction]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: haveapi-typescript-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.31.
|
|
4
|
+
version: 0.31.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jakub Skokan
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.31.
|
|
18
|
+
version: 0.31.1
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.31.
|
|
25
|
+
version: 0.31.1
|
|
26
26
|
executables:
|
|
27
27
|
- haveapi-typescript-client
|
|
28
28
|
extensions: []
|