foobara-remote-imports 0.0.14 → 1.2.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/src/foobara/remote_imports/import_base.rb +21 -11
- data/src/foobara/remote_imports/import_command.rb +40 -3
- metadata +13 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 558b6612de0e763e884d28004f37f3f81af11800f331e7fda886884bb56c0464
|
|
4
|
+
data.tar.gz: 90a1e08d44ac3748b64f72b2d4a989373133f3c05413e6d7552dd46d468cfc53
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ffd376884876fc2fc4d61f20f2a5c6267364b47e58d182e828b5aef87e0e9fb6b88c5a1d2082af30b573351cc6d9d0438820fd187d8bc0070be5028f6c6e004
|
|
7
|
+
data.tar.gz: 64b8821567a88171427344b43e208b251f30ff369c83cd495b220e916ad760c29aea5eac38035645327f0cdcd914fdefc8240985b52a0ec4a42929509ab1fdcf
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [1.2.0] - 2025-10-29
|
|
2
|
+
|
|
3
|
+
- Support auth to get the manifest itself when needed
|
|
4
|
+
- Strip entire path/query string from the manifest URL to get the API url base
|
|
5
|
+
|
|
6
|
+
## [1.1.0] - 2025-08-22
|
|
7
|
+
|
|
8
|
+
- Handle new Foobara 0.1.0 type declarations
|
|
9
|
+
|
|
1
10
|
## [0.0.14] - 2025-05-11
|
|
2
11
|
|
|
3
12
|
- Fix bug that incorrectly leaves a model class anonymous if there's a custom type named "model"
|
|
@@ -96,21 +96,31 @@ module Foobara
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def load_manifest_from_url
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
99
|
+
uri = URI.parse(manifest_url)
|
|
100
|
+
|
|
101
|
+
net_http = Net::HTTP.new(uri.host, uri.port).tap do |http|
|
|
102
|
+
http.use_ssl = uri.scheme == "https"
|
|
103
|
+
http.read_timeout = ENV["FOOBARA_HTTP_MANIFEST_TIMEOUT"]&.to_i || 30
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
request = Net::HTTP::Get.new(uri.request_uri, load_manifest_headers)
|
|
107
|
+
response = net_http.request(request)
|
|
108
|
+
|
|
109
|
+
unless response.is_a?(Net::HTTPSuccess)
|
|
110
|
+
# :nocov:
|
|
111
|
+
raise "Could not get manifest from #{manifest_url}: " \
|
|
112
|
+
"#{response.code} #{response.message}"
|
|
113
|
+
# :nocov:
|
|
114
|
+
end
|
|
115
|
+
manifest_json = response.body
|
|
110
116
|
|
|
111
117
|
JSON.parse(manifest_json)
|
|
112
118
|
end
|
|
113
119
|
|
|
120
|
+
def load_manifest_headers
|
|
121
|
+
{ "Content-Type" => "application/json" }
|
|
122
|
+
end
|
|
123
|
+
|
|
114
124
|
# TODO: feels like a command smell to pass manifests here... reconsider algorithm
|
|
115
125
|
def filter_manifests_to_import
|
|
116
126
|
return if to_import.nil? || to_import.empty?
|
|
@@ -13,10 +13,30 @@ module Foobara
|
|
|
13
13
|
auth_header :tuple,
|
|
14
14
|
element_type_declarations: [:string, :duck],
|
|
15
15
|
description: "A header name, header value/proc pair."
|
|
16
|
+
manifest_requires_auth :boolean, default: false
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
depends_on ImportDomain, ImportType, ImportError
|
|
19
20
|
|
|
21
|
+
def load_manifest_headers
|
|
22
|
+
if manifest_requires_auth
|
|
23
|
+
key = auth_header.first
|
|
24
|
+
value = auth_header.last
|
|
25
|
+
|
|
26
|
+
if value.is_a?(Proc)
|
|
27
|
+
value = if value.lambda? && value.arity == 0
|
|
28
|
+
value.call
|
|
29
|
+
else
|
|
30
|
+
value.call(self)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
super.merge(key => value)
|
|
35
|
+
else
|
|
36
|
+
super
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
20
40
|
def find_manifests_to_import
|
|
21
41
|
root_manifest.commands
|
|
22
42
|
end
|
|
@@ -74,13 +94,30 @@ module Foobara
|
|
|
74
94
|
end
|
|
75
95
|
|
|
76
96
|
def build_command
|
|
77
|
-
url_base = root_manifest.metadata["url"]
|
|
97
|
+
url_base = root_manifest.metadata["url"]
|
|
98
|
+
url_base = URI.parse(url_base)
|
|
99
|
+
url_base = URI::Generic.new(url_base.scheme, url_base.userinfo, url_base.host, url_base.port,
|
|
100
|
+
nil, nil, nil, nil, nil)
|
|
101
|
+
url_base = url_base.to_s
|
|
102
|
+
|
|
103
|
+
domain = Namespace.global.foobara_lookup_domain!(
|
|
104
|
+
manifest_to_import.domain.scoped_full_path,
|
|
105
|
+
mode: Namespace::LookupMode::ABSOLUTE_SINGLE_NAMESPACE
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
inputs_type = nil
|
|
109
|
+
result_type = nil
|
|
110
|
+
|
|
111
|
+
TypeDeclarations.strict_stringified do
|
|
112
|
+
inputs_type = domain.foobara_type_from_declaration(manifest_to_import.inputs_type.relevant_manifest)
|
|
113
|
+
result_type = domain.foobara_type_from_declaration(manifest_to_import.result_type.relevant_manifest)
|
|
114
|
+
end
|
|
78
115
|
|
|
79
116
|
subclass_args = {
|
|
80
117
|
url_base:,
|
|
81
118
|
description: manifest_to_import.description,
|
|
82
|
-
inputs:
|
|
83
|
-
result:
|
|
119
|
+
inputs: inputs_type,
|
|
120
|
+
result: result_type,
|
|
84
121
|
possible_errors: manifest_to_import.possible_errors,
|
|
85
122
|
name: manifest_to_import.reference,
|
|
86
123
|
base: determine_base_command_class
|
metadata
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foobara-remote-imports
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Miles Georgi
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: foobara
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "
|
|
16
|
+
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.0
|
|
18
|
+
version: 0.2.0
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 2.0.0
|
|
19
22
|
type: :runtime
|
|
20
23
|
prerelease: false
|
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
25
|
requirements:
|
|
23
|
-
- - "
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: 0.2.0
|
|
29
|
+
- - "<"
|
|
24
30
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.0
|
|
31
|
+
version: 2.0.0
|
|
26
32
|
email:
|
|
27
33
|
- azimux@gmail.com
|
|
28
34
|
executables: []
|
|
@@ -65,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
65
71
|
- !ruby/object:Gem::Version
|
|
66
72
|
version: '0'
|
|
67
73
|
requirements: []
|
|
68
|
-
rubygems_version: 3.6.
|
|
74
|
+
rubygems_version: 3.6.9
|
|
69
75
|
specification_version: 4
|
|
70
76
|
summary: Used to import commands/entities/whatever from another system into this one.
|
|
71
77
|
test_files: []
|