@seamapi/nextlove-sdk-generator 1.5.5 → 1.5.7
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.
- package/lib/generate-php-sdk/generate-php-sdk.js +4 -4
- package/lib/generate-php-sdk/generate-php-sdk.js.map +1 -1
- package/lib/generate-python-sdk/class-file.js +8 -5
- package/lib/generate-python-sdk/class-file.js.map +1 -1
- package/lib/generate-python-sdk/generate-python-sdk.js +3 -4
- package/lib/generate-python-sdk/generate-python-sdk.js.map +1 -1
- package/lib/generate-ruby-sdk/generate-ruby-sdk.js +33 -14
- package/lib/generate-ruby-sdk/generate-ruby-sdk.js.map +1 -1
- package/lib/generate-ruby-sdk/ruby-client.d.ts +8 -2
- package/lib/generate-ruby-sdk/ruby-client.js +25 -6
- package/lib/generate-ruby-sdk/ruby-client.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/.rspec.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/.rspec.template.js +4 -0
- package/lib/generate-ruby-sdk/templates/.rspec.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/.ruby-version.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/.ruby-version.template.js +2 -0
- package/lib/generate-ruby-sdk/templates/.ruby-version.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/base_resource.rb.template.js +2 -2
- package/lib/generate-ruby-sdk/templates/client.rb.template.d.ts +1 -1
- package/lib/generate-ruby-sdk/templates/client.rb.template.js +60 -73
- package/lib/generate-ruby-sdk/templates/client.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/request.rb.template.js +1 -1
- package/lib/generate-ruby-sdk/templates/resource_error.rb.template.js +2 -0
- package/lib/generate-ruby-sdk/templates/resource_error.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/resource_warning.rb.template.js +2 -0
- package/lib/generate-ruby-sdk/templates/resource_warning.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.js +2 -2
- package/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.js +28 -0
- package/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.js +26 -7
- package/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.js.map +1 -1
- package/lib/generate-ruby-sdk/templates/spec_helper.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/spec_helper.rb.template.js +29 -0
- package/lib/generate-ruby-sdk/templates/spec_helper.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/support-helpers.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/support-helpers.rb.template.js +12 -0
- package/lib/generate-ruby-sdk/templates/support-helpers.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/version.rb.template.js +1 -1
- package/lib/openapi/map-parent-to-children-resource.d.ts +2 -2
- package/lib/openapi/map-parent-to-children-resource.js +2 -2
- package/lib/openapi/map-parent-to-children-resource.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/generate-php-sdk/generate-php-sdk.ts +4 -4
- package/src/lib/generate-python-sdk/class-file.ts +9 -6
- package/src/lib/generate-python-sdk/generate-python-sdk.ts +3 -4
- package/src/lib/generate-ruby-sdk/generate-ruby-sdk.ts +47 -14
- package/src/lib/generate-ruby-sdk/ruby-client.ts +42 -7
- package/src/lib/generate-ruby-sdk/templates/.rspec.template.ts +3 -0
- package/src/lib/generate-ruby-sdk/templates/.ruby-version.template.ts +1 -0
- package/src/lib/generate-ruby-sdk/templates/base_resource.rb.template.ts +2 -2
- package/src/lib/generate-ruby-sdk/templates/client.rb.template.ts +62 -73
- package/src/lib/generate-ruby-sdk/templates/request.rb.template.ts +1 -1
- package/src/lib/generate-ruby-sdk/templates/resource_error.rb.template.ts +2 -0
- package/src/lib/generate-ruby-sdk/templates/resource_warning.rb.template.ts +2 -0
- package/src/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.ts +2 -2
- package/src/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.ts +27 -0
- package/src/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.ts +34 -9
- package/src/lib/generate-ruby-sdk/templates/spec_helper.rb.template.ts +28 -0
- package/src/lib/generate-ruby-sdk/templates/support-helpers.rb.template.ts +11 -0
- package/src/lib/generate-ruby-sdk/templates/version.rb.template.ts +1 -1
- package/src/lib/openapi/map-parent-to-children-resource.ts +2 -4
|
@@ -1,74 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def request_seam(method, path, config = {})
|
|
64
|
-
Seam::Request.new(
|
|
65
|
-
api_key: api_key,
|
|
66
|
-
base_uri: base_uri,
|
|
67
|
-
debug: debug
|
|
68
|
-
).perform(
|
|
69
|
-
method, path, config
|
|
70
|
-
)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end`;
|
|
1
|
+
import { pascalCase } from "change-case";
|
|
2
|
+
export default (resource_client_names) => {
|
|
3
|
+
const resource_client_defs = resource_client_names
|
|
4
|
+
.map((client_name) => {
|
|
5
|
+
return `
|
|
6
|
+
def ${client_name}
|
|
7
|
+
@${client_name} ||= Seam::Clients::${pascalCase(client_name)}.new(self)
|
|
8
|
+
end
|
|
9
|
+
`;
|
|
10
|
+
})
|
|
11
|
+
.join("");
|
|
12
|
+
return `# frozen_string_literal: true
|
|
13
|
+
|
|
14
|
+
module Seam
|
|
15
|
+
class Client
|
|
16
|
+
attr_accessor :api_key, :base_uri, :debug
|
|
17
|
+
|
|
18
|
+
def initialize(api_key: nil, base_uri: "https://connect.getseam.com", debug: false)
|
|
19
|
+
@api_key = api_key || ENV.fetch("SEAM_API_KEY", nil)
|
|
20
|
+
@base_uri = base_uri
|
|
21
|
+
@debug = debug
|
|
22
|
+
|
|
23
|
+
raise ArgumentError, "SEAM_API_KEY not found in environment, and api_key not provided" unless @api_key
|
|
24
|
+
end
|
|
25
|
+
${resource_client_defs}
|
|
26
|
+
|
|
27
|
+
# @deprecated Please use {#devices.unmanaged} instead.
|
|
28
|
+
def unmanaged_devices
|
|
29
|
+
warn "[DEPRECATION] 'unmanaged_devices' is deprecated. Please use 'devices.unmanaged' instead."
|
|
30
|
+
|
|
31
|
+
@unmanaged_devices ||= Seam::Clients::DevicesUnmanaged.new(self)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @deprecated Please use {#access_codes.unmanaged} instead.
|
|
35
|
+
def unmanaged_access_codes
|
|
36
|
+
warn "[DEPRECATION] 'unmanaged_access_codes' is deprecated. Please use 'access_codes.unmanaged' instead."
|
|
37
|
+
|
|
38
|
+
@unmanaged_access_codes ||= Seam::Clients::AccessCodesUnmanaged.new(self)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def request_seam_object(method, path, klass, inner_object, config = {})
|
|
42
|
+
response = request_seam(method, path, config)
|
|
43
|
+
|
|
44
|
+
data = response[inner_object]
|
|
45
|
+
|
|
46
|
+
klass.load_from_response(data, self)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def request_seam(method, path, config = {})
|
|
50
|
+
Seam::Request.new(
|
|
51
|
+
api_key: api_key,
|
|
52
|
+
base_uri: base_uri,
|
|
53
|
+
debug: debug
|
|
54
|
+
).perform(
|
|
55
|
+
method, path, config
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end`;
|
|
60
|
+
};
|
|
74
61
|
//# sourceMappingURL=client.rb.template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/client.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"client.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/client.rb.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,eAAe,CAAC,qBAA+B,EAAE,EAAE;IACjD,MAAM,oBAAoB,GAAG,qBAAqB;SAC/C,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;QACnB,OAAO;YACD,WAAW;WACZ,WAAW,uBAAuB,UAAU,CAAC,WAAW,CAAC;;OAE7D,CAAA;IACH,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAA;IAEX,OAAO;;;;;;;;;;;;;QAaD,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkCtB,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -45,7 +45,7 @@ module Seam
|
|
|
45
45
|
code = response.status.code
|
|
46
46
|
|
|
47
47
|
if code >= 400 && code < 500 && (err = response.parse["error"])
|
|
48
|
-
msg = "Api Error #{err["type"]}
|
|
48
|
+
msg = "Api Error #{err["type"]}\\nrequest_id: #{err["request_id"]}\\n#{err["message"]}"
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
raise Error.new(msg, code, response)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource_error.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/resource_error.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"resource_error.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/resource_error.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;IAQjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource_warning.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/resource_warning.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"resource_warning.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/resource_warning.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;IAQjB,CAAA"}
|
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
|
6
6
|
spec.name = "seamapi"
|
|
7
7
|
spec.version = Seam::VERSION
|
|
8
8
|
spec.author = "Seam Labs, Inc."
|
|
9
|
-
spec.email = "
|
|
9
|
+
spec.email = "devops@getseam.com"
|
|
10
10
|
|
|
11
11
|
spec.summary = "Seam API Ruby SDK"
|
|
12
12
|
spec.description = "Official interface to the Seam Connect API."
|
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
spec.files = Dir["lib/**/*.rb"]
|
|
27
27
|
spec.files += Dir["[A-Z]*"]
|
|
28
28
|
|
|
29
|
-
spec.add_dependency "http", "~> 5.0
|
|
29
|
+
spec.add_dependency "http", "~> 5.0"
|
|
30
30
|
|
|
31
31
|
spec.add_development_dependency "bundler", "~> 2.0"
|
|
32
32
|
spec.add_development_dependency "gem-release", "~> 2.2"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default () => `SLEEP_TIME = 0.2
|
|
2
|
+
MAX_ATTEMPTS = 10
|
|
3
|
+
|
|
4
|
+
def wait_until_finished
|
|
5
|
+
attempts = 0
|
|
6
|
+
while @status == "pending"
|
|
7
|
+
update!
|
|
8
|
+
sleep(SLEEP_TIME)
|
|
9
|
+
attempts += 1
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
raise "Timed out waiting for action attempt to finish" if attempts >= MAX_ATTEMPTS
|
|
13
|
+
|
|
14
|
+
self
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def update!
|
|
18
|
+
response = @client.request_seam(
|
|
19
|
+
:post,
|
|
20
|
+
"/action_attempts/get",
|
|
21
|
+
body: {
|
|
22
|
+
action_attempt_id: action_attempt_id
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
update_from_response(response["action_attempt"])
|
|
27
|
+
end`;
|
|
28
|
+
//# sourceMappingURL=action-attempt-helpers-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-attempt-helpers-template.js","sourceRoot":"","sources":["../../../../src/lib/generate-ruby-sdk/templates/snippets/action-attempt-helpers-template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;QA0Bb,CAAA"}
|
|
@@ -1,15 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import actionAttemptHelpersTemplate from "./action-attempt-helpers-template.js";
|
|
2
|
+
export default ({ pascal_name, attrs, date_attrs, }) => {
|
|
3
|
+
const no_error_warning_attrs = attrs.filter((attr) => attr !== "errors" && attr !== "warnings");
|
|
4
|
+
const has_warnings_attr = attrs.includes("warnings");
|
|
5
|
+
const has_errors_attr = attrs.includes("errors");
|
|
6
|
+
const attr_accessors = no_error_warning_attrs
|
|
7
|
+
.map((attr) => `:${attr}`)
|
|
8
|
+
.join(", ");
|
|
9
|
+
const date_accessors = date_attrs.length > 0
|
|
10
|
+
? `date_accessor ${date_attrs.map((attr) => `:${attr}`).join(", ")}`
|
|
11
|
+
: "";
|
|
12
|
+
const resource_errors_support = has_errors_attr
|
|
13
|
+
? "include Seam::ResourceErrorsSupport"
|
|
14
|
+
: "";
|
|
15
|
+
const resource_warnings_support = has_warnings_attr
|
|
16
|
+
? "include Seam::ResourceWarningsSupport"
|
|
17
|
+
: "";
|
|
18
|
+
const is_action_attempt_resource = pascal_name === "ActionAttempt";
|
|
19
|
+
return `# frozen_string_literal: true
|
|
2
20
|
|
|
3
21
|
module Seam
|
|
4
22
|
class ${pascal_name} < BaseResource
|
|
5
|
-
|
|
23
|
+
attr_accessor ${attr_accessors}
|
|
6
24
|
|
|
7
|
-
${
|
|
8
|
-
? `date_accessor ${date_attrs.map((attr) => `:${attr}`).join(", ")}`
|
|
9
|
-
: ""}
|
|
25
|
+
${date_accessors}
|
|
10
26
|
|
|
11
|
-
|
|
12
|
-
|
|
27
|
+
${resource_errors_support}
|
|
28
|
+
${resource_warnings_support}
|
|
29
|
+
|
|
30
|
+
${is_action_attempt_resource ? actionAttemptHelpersTemplate() : ""}
|
|
13
31
|
end
|
|
14
32
|
end`;
|
|
33
|
+
};
|
|
15
34
|
//# sourceMappingURL=resource.rb.template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.rb.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,CAAC,EACd,WAAW,EACX,KAAK,EACL,UAAU,GAKX,EAAE,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"resource.rb.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,sCAAsC,CAAA;AAE/E,eAAe,CAAC,EACd,WAAW,EACX,KAAK,EACL,UAAU,GAKX,EAAE,EAAE;IACH,MAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CACzC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,UAAU,CACnD,CAAA;IACD,MAAM,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IACpD,MAAM,eAAe,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAEhD,MAAM,cAAc,GAAG,sBAAsB;SAC1C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,MAAM,cAAc,GAClB,UAAU,CAAC,MAAM,GAAG,CAAC;QACnB,CAAC,CAAC,iBAAiB,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACpE,CAAC,CAAC,EAAE,CAAA;IAER,MAAM,uBAAuB,GAAG,eAAe;QAC7C,CAAC,CAAC,qCAAqC;QACvC,CAAC,CAAC,EAAE,CAAA;IACN,MAAM,yBAAyB,GAAG,iBAAiB;QACjD,CAAC,CAAC,uCAAuC;QACzC,CAAC,CAAC,EAAE,CAAA;IAEN,MAAM,0BAA0B,GAAG,WAAW,KAAK,eAAe,CAAA;IAElE,OAAO;;;UAGC,WAAW;oBACD,cAAc;;MAE5B,cAAc;;MAEd,uBAAuB;MACvB,yBAAyB;;QAEvB,0BAA0B,CAAC,CAAC,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC,EAAE;;IAEpE,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default () => `# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "simplecov"
|
|
4
|
+
require "simplecov-console"
|
|
5
|
+
|
|
6
|
+
SimpleCov.start
|
|
7
|
+
|
|
8
|
+
require "seamapi"
|
|
9
|
+
require "webmock/rspec"
|
|
10
|
+
|
|
11
|
+
require_relative "support/helpers"
|
|
12
|
+
|
|
13
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
|
14
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
15
|
+
SimpleCov::Formatter::Console
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
RSpec.configure do |config|
|
|
19
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
|
20
|
+
|
|
21
|
+
config.disable_monkey_patching!
|
|
22
|
+
|
|
23
|
+
config.expect_with :rspec do |c|
|
|
24
|
+
c.syntax = :expect
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
config.include Helpers
|
|
28
|
+
end`;
|
|
29
|
+
//# sourceMappingURL=spec_helper.rb.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec_helper.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/spec_helper.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BjB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default () => `# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Helpers
|
|
4
|
+
def stub_seam_request(method, path, response, status: 200, headers: {})
|
|
5
|
+
stub_request(
|
|
6
|
+
method,
|
|
7
|
+
"https://connect.getseam.com#{path}"
|
|
8
|
+
).to_return(status: status, body: response.to_json,
|
|
9
|
+
headers: {"Content-Type" => "application/json"}.merge(headers))
|
|
10
|
+
end
|
|
11
|
+
end`;
|
|
12
|
+
//# sourceMappingURL=support-helpers.rb.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support-helpers.rb.template.js","sourceRoot":"","sources":["../../../src/lib/generate-ruby-sdk/templates/support-helpers.rb.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;IAUjB,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Route } from "../../lib/types.js";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const mapParentToChildResources: (routes: Route[]) => Record<string, string[]>;
|
|
3
|
+
export default mapParentToChildResources;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const mapParentToChildResources = (routes) => routes.reduce((acc, route) => {
|
|
2
2
|
if (!route.post?.["x-fern-sdk-group-name"])
|
|
3
3
|
return acc;
|
|
4
4
|
const [parent_resource_name, child_resource_name] = route.post["x-fern-sdk-group-name"];
|
|
@@ -13,5 +13,5 @@ const mapParentToChildrenResources = (routes) => routes.reduce((acc, route) => {
|
|
|
13
13
|
}
|
|
14
14
|
return acc;
|
|
15
15
|
}, {});
|
|
16
|
-
export default
|
|
16
|
+
export default mapParentToChildResources;
|
|
17
17
|
//# sourceMappingURL=map-parent-to-children-resource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-parent-to-children-resource.js","sourceRoot":"","sources":["../../src/lib/openapi/map-parent-to-children-resource.ts"],"names":[],"mappings":"AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"map-parent-to-children-resource.js","sourceRoot":"","sources":["../../src/lib/openapi/map-parent-to-children-resource.ts"],"names":[],"mappings":"AAEA,MAAM,yBAAyB,GAAG,CAAC,MAAe,EAA4B,EAAE,CAC9E,MAAM,CAAC,MAAM,CAAC,CAAC,GAA6B,EAAE,KAAK,EAAE,EAAE;IACrD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,uBAAuB,CAAC;QAAE,OAAO,GAAG,CAAA;IAEtD,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,GAC/C,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;IAErC,IAAI,CAAC,oBAAoB;QAAE,OAAO,GAAG,CAAA;IAErC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE;QAC9B,GAAG,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAAA;KAC/B;IAED,IACE,mBAAmB;QACnB,CAAC,GAAG,CAAC,oBAAoB,CAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EACzD;QACA,GAAG,CAAC,oBAAoB,CAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;KACrD;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AAER,eAAe,yBAAyB,CAAA"}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ import gitignoreTemplate from "./templates/gitignore.template.js"
|
|
|
14
14
|
import envExampleTemplate from "./templates/env.example.template.js"
|
|
15
15
|
import testFixtureTemplate from "./templates/test-fixture.template.js"
|
|
16
16
|
import smokeTestTemplate from "./templates/smoke-test.template.js"
|
|
17
|
-
import
|
|
17
|
+
import mapParentToChildResources from "lib/openapi/map-parent-to-children-resource.js"
|
|
18
18
|
|
|
19
19
|
export const generatePhpSDK = async () => {
|
|
20
20
|
const openapi: OpenAPISchema = await axios
|
|
@@ -65,18 +65,18 @@ export const generatePhpSDK = async () => {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const
|
|
68
|
+
const parent_to_child_resources_map = mapParentToChildResources(routes)
|
|
69
69
|
const clients: Record<string, PhpClient> = {}
|
|
70
70
|
|
|
71
71
|
const processClient = (resource_name: string) => {
|
|
72
72
|
const child_client_identifiers: PhpClientIdentifier[] = (
|
|
73
|
-
|
|
73
|
+
parent_to_child_resources_map[resource_name] ?? []
|
|
74
74
|
).map((child_resource) => ({
|
|
75
75
|
client_name: pascalCase(`${resource_name} ${child_resource}`),
|
|
76
76
|
namespace: child_resource,
|
|
77
77
|
}))
|
|
78
78
|
const is_parent_client = Object.keys(
|
|
79
|
-
|
|
79
|
+
parent_to_child_resources_map
|
|
80
80
|
).includes(resource_name)
|
|
81
81
|
const pascal_resource_name = pascalCase(resource_name)
|
|
82
82
|
|
|
@@ -128,6 +128,7 @@ export class ClassFile {
|
|
|
128
128
|
),
|
|
129
129
|
].filter((classInstance) => classInstance !== "")
|
|
130
130
|
const has_child_classes = this.child_class_identifiers.length > 0
|
|
131
|
+
const is_action_attempt_class = this.name === "ActionAttempts"
|
|
131
132
|
|
|
132
133
|
return [
|
|
133
134
|
`from seamapi.types import (${validClasses
|
|
@@ -144,7 +145,7 @@ export class ClassFile {
|
|
|
144
145
|
.join("\n")
|
|
145
146
|
: ""
|
|
146
147
|
}`,
|
|
147
|
-
`${
|
|
148
|
+
`${is_action_attempt_class ? "import time\n" : ""}`,
|
|
148
149
|
|
|
149
150
|
`class ${this.name}(Abstract${this.name}):`,
|
|
150
151
|
// TODO DOCSTRING
|
|
@@ -185,8 +186,10 @@ export class ClassFile {
|
|
|
185
186
|
return_resource_item = return_resource.slice(5, -1)
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
const
|
|
189
|
-
|
|
189
|
+
const can_method_poll_action_attempt =
|
|
190
|
+
!is_action_attempt_class &&
|
|
191
|
+
return_resource === "ActionAttempt" &&
|
|
192
|
+
!is_return_resource_list
|
|
190
193
|
const is_none_return_type = return_resource_item === "None"
|
|
191
194
|
|
|
192
195
|
return [
|
|
@@ -204,7 +207,7 @@ export class ClassFile {
|
|
|
204
207
|
: `${name}: Optional[${type}] = None`
|
|
205
208
|
)
|
|
206
209
|
.concat(
|
|
207
|
-
|
|
210
|
+
can_method_poll_action_attempt
|
|
208
211
|
? [
|
|
209
212
|
"wait_for_action_attempt: Union[bool, Dict[str, float]] = True",
|
|
210
213
|
]
|
|
@@ -228,7 +231,7 @@ export class ClassFile {
|
|
|
228
231
|
` )`,
|
|
229
232
|
"",
|
|
230
233
|
|
|
231
|
-
|
|
234
|
+
can_method_poll_action_attempt
|
|
232
235
|
? [
|
|
233
236
|
" if isinstance(wait_for_action_attempt, dict):",
|
|
234
237
|
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
@@ -250,7 +253,7 @@ export class ClassFile {
|
|
|
250
253
|
: "",
|
|
251
254
|
"",
|
|
252
255
|
|
|
253
|
-
!
|
|
256
|
+
!can_method_poll_action_attempt
|
|
254
257
|
? is_none_return_type
|
|
255
258
|
? ` return None`
|
|
256
259
|
: is_return_resource_list
|
|
@@ -21,7 +21,7 @@ import reportErrorTemplate from "./templates/utils/report_error.py.template.js"
|
|
|
21
21
|
import getSentryDsnTemplate from "./templates/utils/get_sentry_dsn.py.template.js"
|
|
22
22
|
import SeamApiExceptionClassTemplate from "./templates/snippets/seam-api-exception-class.template.js"
|
|
23
23
|
import { getParameterAndResponseSchema } from "lib/openapi/get-parameter-and-response-schema.js"
|
|
24
|
-
import
|
|
24
|
+
import mapParentToChildResources from "lib/openapi/map-parent-to-children-resource.js"
|
|
25
25
|
import { deepFlattenOneOfAndAllOfSchema } from "lib/generate-php-sdk/utils/deep-flatten-one-of-and-all-of-schema.js"
|
|
26
26
|
import endpoints_returning_deprecated_action_attempt from "lib/endpoints-returning-deprecated-action-attempt.js"
|
|
27
27
|
|
|
@@ -37,11 +37,11 @@ export const generatePythonSDK = async () => {
|
|
|
37
37
|
const fs: any = {}
|
|
38
38
|
const class_map: Record<string, ClassFile> = {}
|
|
39
39
|
const namespaces: string[][] = []
|
|
40
|
-
const
|
|
40
|
+
const parent_to_child_resources_map = mapParentToChildResources(routes)
|
|
41
41
|
|
|
42
42
|
const processClass = (resource_name: string) => {
|
|
43
43
|
const child_class_identifiers = (
|
|
44
|
-
|
|
44
|
+
parent_to_child_resources_map[resource_name] ?? []
|
|
45
45
|
).map((child_resource) => ({
|
|
46
46
|
class_name: pascalCase(`${resource_name} ${child_resource}`),
|
|
47
47
|
namespace: child_resource,
|
|
@@ -61,7 +61,6 @@ export const generatePythonSDK = async () => {
|
|
|
61
61
|
const group_names = [...route.post["x-fern-sdk-group-name"]]
|
|
62
62
|
const [base_resource] = group_names
|
|
63
63
|
const namespace = group_names.join("_")
|
|
64
|
-
group_names.reverse()
|
|
65
64
|
const class_name = pascalCase(namespace)
|
|
66
65
|
|
|
67
66
|
if (!class_map[class_name]) {
|
|
@@ -14,11 +14,16 @@ import loggerRbTemplate from "./templates/logger.rb.template.js"
|
|
|
14
14
|
import clientRbTemplate from "./templates/client.rb.template.js"
|
|
15
15
|
import gemfileTemplate from "./templates/gemfile.template.js"
|
|
16
16
|
import seamapiGemspecTemplate from "./templates/seamapi.gemspec.template.js"
|
|
17
|
+
import rspecTemplate from "./templates/.rspec.template.js"
|
|
18
|
+
import rubyVersionTemplate from "./templates/.ruby-version.template.js"
|
|
19
|
+
import supportHelpersTemplate from "./templates/support-helpers.rb.template.js"
|
|
20
|
+
import specHelperTemplate from "./templates/spec_helper.rb.template.js"
|
|
17
21
|
import base_resourceRbTemplate from "./templates/base_resource.rb.template.js"
|
|
18
22
|
import resource_errorRbTemplate from "./templates/resource_error.rb.template.js"
|
|
19
23
|
import resource_warningRbTemplate from "./templates/resource_warning.rb.template.js"
|
|
20
24
|
import resource_errors_supportRbTemplate from "./templates/resource_errors_support.rb.template.js"
|
|
21
25
|
import resource_warnings_supportRbTemplate from "./templates/resource_warnings_support.rb.template.js"
|
|
26
|
+
import mapParentToChildResources from "lib/openapi/map-parent-to-children-resource.js"
|
|
22
27
|
|
|
23
28
|
export const generateRubySDK = async () => {
|
|
24
29
|
const openapi: OpenAPISchema = await axios
|
|
@@ -33,14 +38,16 @@ export const generateRubySDK = async () => {
|
|
|
33
38
|
|
|
34
39
|
fs["README.md"] = readmeMdTemplate()
|
|
35
40
|
fs["Rakefile"] = rakefileTemplate()
|
|
36
|
-
fs["spec/spec_helper.rb"] =
|
|
41
|
+
fs["spec/spec_helper.rb"] = specHelperTemplate()
|
|
42
|
+
fs["spec/support/helpers.rb"] = supportHelpersTemplate()
|
|
37
43
|
fs["spec/smoketest.rb"] = ""
|
|
38
44
|
fs["Gemfile"] = gemfileTemplate()
|
|
39
45
|
fs["seamapi.gemspec"] = seamapiGemspecTemplate()
|
|
46
|
+
fs[".rspec"] = rspecTemplate()
|
|
47
|
+
fs[".ruby-version"] = rubyVersionTemplate()
|
|
40
48
|
fs["lib/seam/version.rb"] = versionRbTemplate()
|
|
41
49
|
fs["lib/seam/request.rb"] = requestRbTemplate()
|
|
42
50
|
fs["lib/seam/logger.rb"] = loggerRbTemplate()
|
|
43
|
-
fs["lib/seam/client.rb"] = clientRbTemplate()
|
|
44
51
|
fs["lib/seam/clients/base_client.rb"] = base_clientRbTemplate()
|
|
45
52
|
fs["lib/seam/resources/base_resource.rb"] = base_resourceRbTemplate()
|
|
46
53
|
fs["lib/seam/resources/resource_error.rb"] = resource_errorRbTemplate()
|
|
@@ -85,21 +92,46 @@ export const generateRubySDK = async () => {
|
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
const clients: Record<string, RubyClient> = {}
|
|
95
|
+
const parent_to_child_resources_map = mapParentToChildResources(routes)
|
|
96
|
+
|
|
97
|
+
const processClient = (resource_name: string) => {
|
|
98
|
+
const child_class_identifiers = (
|
|
99
|
+
parent_to_child_resources_map[resource_name] ?? []
|
|
100
|
+
).map((child_resource) => ({
|
|
101
|
+
client_name: pascalCase(`${resource_name} ${child_resource}`),
|
|
102
|
+
namespace: child_resource,
|
|
103
|
+
}))
|
|
104
|
+
const pascal_resource_name = pascalCase(resource_name)
|
|
105
|
+
|
|
106
|
+
clients[pascal_resource_name] = new RubyClient(
|
|
107
|
+
pascal_resource_name,
|
|
108
|
+
resource_name,
|
|
109
|
+
child_class_identifiers
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
88
113
|
for (const route of routes) {
|
|
89
114
|
if (!route.post) continue
|
|
90
115
|
if (!route.post["x-fern-sdk-group-name"]) continue
|
|
91
116
|
const group_names = [...route.post["x-fern-sdk-group-name"]]
|
|
117
|
+
const [base_resource] = group_names
|
|
92
118
|
const namespace = group_names.join("_")
|
|
93
|
-
group_names.
|
|
94
|
-
|
|
95
|
-
if (!clients[
|
|
96
|
-
|
|
97
|
-
|
|
119
|
+
const client_name = pascalCase(group_names.join("_"))
|
|
120
|
+
|
|
121
|
+
if (!clients[client_name]) processClient(namespace)
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
special case when we don't have routes for a base resource
|
|
125
|
+
and thus a respective x-fern-sdk-group-name for ex. /noise_sensors
|
|
126
|
+
*/
|
|
127
|
+
if (base_resource && !clients[pascalCase(base_resource)]) {
|
|
128
|
+
processClient(base_resource)
|
|
98
129
|
}
|
|
99
|
-
|
|
130
|
+
|
|
131
|
+
const client = clients[client_name]
|
|
100
132
|
|
|
101
133
|
if (!client) {
|
|
102
|
-
console.warn(`No client for "${
|
|
134
|
+
console.warn(`No client for "${client_name}", skipping`)
|
|
103
135
|
continue
|
|
104
136
|
}
|
|
105
137
|
|
|
@@ -111,10 +143,7 @@ export const generateRubySDK = async () => {
|
|
|
111
143
|
continue
|
|
112
144
|
}
|
|
113
145
|
|
|
114
|
-
|
|
115
|
-
console.warn(`No response object/array ref for "${route.path}", skipping`)
|
|
116
|
-
continue
|
|
117
|
-
}
|
|
146
|
+
const return_resource = response_obj_type ?? response_arr_type
|
|
118
147
|
|
|
119
148
|
client.addMethod({
|
|
120
149
|
method_name: route.post["x-fern-sdk-method-name"],
|
|
@@ -131,7 +160,7 @@ export const generateRubySDK = async () => {
|
|
|
131
160
|
: undefined,
|
|
132
161
|
})),
|
|
133
162
|
return_path: route.post["x-fern-sdk-return-value"],
|
|
134
|
-
return_resource: pascalCase(
|
|
163
|
+
return_resource: return_resource ? pascalCase(return_resource) : null,
|
|
135
164
|
})
|
|
136
165
|
}
|
|
137
166
|
|
|
@@ -140,6 +169,10 @@ export const generateRubySDK = async () => {
|
|
|
140
169
|
seamapi_rb_requires.push(`seam/clients/${client.snake_name}`)
|
|
141
170
|
}
|
|
142
171
|
|
|
172
|
+
fs["lib/seam/client.rb"] = clientRbTemplate(
|
|
173
|
+
Object.keys(parent_to_child_resources_map)
|
|
174
|
+
)
|
|
175
|
+
|
|
143
176
|
fs["lib/seamapi.rb"] = [
|
|
144
177
|
`# frozen_string_literal: true`,
|
|
145
178
|
"",
|