@seamapi/nextlove-sdk-generator 1.5.6 → 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 +4 -4
- 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 +4 -4
- 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
|
@@ -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
|
|
|
@@ -186,7 +186,7 @@ export class ClassFile {
|
|
|
186
186
|
return_resource_item = return_resource.slice(5, -1)
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
const
|
|
189
|
+
const can_method_poll_action_attempt =
|
|
190
190
|
!is_action_attempt_class &&
|
|
191
191
|
return_resource === "ActionAttempt" &&
|
|
192
192
|
!is_return_resource_list
|
|
@@ -207,7 +207,7 @@ export class ClassFile {
|
|
|
207
207
|
: `${name}: Optional[${type}] = None`
|
|
208
208
|
)
|
|
209
209
|
.concat(
|
|
210
|
-
|
|
210
|
+
can_method_poll_action_attempt
|
|
211
211
|
? [
|
|
212
212
|
"wait_for_action_attempt: Union[bool, Dict[str, float]] = True",
|
|
213
213
|
]
|
|
@@ -231,7 +231,7 @@ export class ClassFile {
|
|
|
231
231
|
` )`,
|
|
232
232
|
"",
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
can_method_poll_action_attempt
|
|
235
235
|
? [
|
|
236
236
|
" if isinstance(wait_for_action_attempt, dict):",
|
|
237
237
|
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
@@ -253,7 +253,7 @@ export class ClassFile {
|
|
|
253
253
|
: "",
|
|
254
254
|
"",
|
|
255
255
|
|
|
256
|
-
!
|
|
256
|
+
!can_method_poll_action_attempt
|
|
257
257
|
? is_none_return_type
|
|
258
258
|
? ` return None`
|
|
259
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
|
"",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import endpoints_returning_deprecated_action_attempt from "lib/endpoints-returning-deprecated-action-attempt.js"
|
|
2
|
+
|
|
1
3
|
export type RubyClientMethodParameter = {
|
|
2
4
|
name: string
|
|
3
5
|
required?: boolean | undefined
|
|
@@ -8,18 +10,26 @@ export type RubyClientMethod = {
|
|
|
8
10
|
method_name: string
|
|
9
11
|
path: string
|
|
10
12
|
parameters: RubyClientMethodParameter[]
|
|
11
|
-
return_resource: string
|
|
13
|
+
return_resource: string | null
|
|
12
14
|
return_path: string
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
type ChildClientIdentifier = {
|
|
18
|
+
client_name: string
|
|
19
|
+
namespace: string
|
|
20
|
+
}
|
|
21
|
+
|
|
15
22
|
export class RubyClient {
|
|
16
23
|
methods: RubyClientMethod[] = []
|
|
24
|
+
child_client_identifiers: ChildClientIdentifier[]
|
|
17
25
|
|
|
18
26
|
constructor(
|
|
19
27
|
public pascal_name: string,
|
|
20
|
-
public snake_name: string
|
|
28
|
+
public snake_name: string,
|
|
29
|
+
child_client_identifiers: ChildClientIdentifier[]
|
|
21
30
|
) {
|
|
22
31
|
this.methods = []
|
|
32
|
+
this.child_client_identifiers = child_client_identifiers
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
addMethod(method: RubyClientMethod) {
|
|
@@ -43,13 +53,30 @@ export class RubyClient {
|
|
|
43
53
|
*/
|
|
44
54
|
serialize() {
|
|
45
55
|
return [
|
|
56
|
+
`# frozen_string_literal: true`,
|
|
57
|
+
``,
|
|
46
58
|
`module Seam`,
|
|
47
59
|
` module Clients`,
|
|
48
60
|
` class ${this.pascal_name} < BaseClient`,
|
|
61
|
+
...this.child_client_identifiers.map(({ client_name, namespace }) =>
|
|
62
|
+
[
|
|
63
|
+
`def ${namespace}`,
|
|
64
|
+
` @${namespace} ||= Seam::Clients::${client_name}.new(self)`,
|
|
65
|
+
`end`,
|
|
66
|
+
``,
|
|
67
|
+
]
|
|
68
|
+
.flatMap((s) => ` ${s}`)
|
|
69
|
+
.join("\n")
|
|
70
|
+
),
|
|
49
71
|
...this.methods.map(
|
|
50
72
|
({ method_name, path, parameters, return_resource, return_path }) => {
|
|
73
|
+
const is_action_attempt_client = this.pascal_name === "ActionAttempts"
|
|
74
|
+
const can_method_poll_action_attempt =
|
|
75
|
+
!endpoints_returning_deprecated_action_attempt.includes(path) &&
|
|
76
|
+
!is_action_attempt_client &&
|
|
77
|
+
return_resource === "ActionAttempt"
|
|
78
|
+
|
|
51
79
|
return [
|
|
52
|
-
" ",
|
|
53
80
|
`def ${method_name}(${parameters
|
|
54
81
|
.sort(
|
|
55
82
|
(a, b) =>
|
|
@@ -58,18 +85,26 @@ export class RubyClient {
|
|
|
58
85
|
)
|
|
59
86
|
.map((p) => `${p.name}${p.required ? "" : ": nil"}`)
|
|
60
87
|
.join(", ")})`,
|
|
61
|
-
`
|
|
88
|
+
` ${can_method_poll_action_attempt ? "action_attempt = " : ""}${
|
|
89
|
+
return_resource ? "request_seam_object" : "request_seam"
|
|
90
|
+
}(`,
|
|
62
91
|
` :post,`,
|
|
63
92
|
` "${path}",`,
|
|
64
|
-
`
|
|
65
|
-
` '${return_path}'
|
|
93
|
+
return_resource ? ` Seam::${return_resource},` : [],
|
|
94
|
+
return_path ? ` '${return_path}',` : [],
|
|
66
95
|
` body: {${parameters
|
|
67
96
|
.map((p) => `${p.name}: ${p.name}`)
|
|
68
97
|
.join(", ")}}.compact`,
|
|
69
98
|
` )`,
|
|
99
|
+
` ${
|
|
100
|
+
can_method_poll_action_attempt
|
|
101
|
+
? "action_attempt.wait_until_finished\n action_attempt"
|
|
102
|
+
: ""
|
|
103
|
+
}`,
|
|
70
104
|
`end`,
|
|
105
|
+
``,
|
|
71
106
|
]
|
|
72
|
-
.
|
|
107
|
+
.flatMap((s) => ` ${s}`)
|
|
73
108
|
.join("\n")
|
|
74
109
|
}
|
|
75
110
|
),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default () => `3.0.4`
|
|
@@ -29,12 +29,12 @@ module Seam
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def inspect
|
|
32
|
-
"<#{self.class.name}:#{"0x00%x" % (object_id << 1)}
|
|
32
|
+
"<#{self.class.name}:#{"0x00%x" % (object_id << 1)}\\n" + # rubocop:disable Style/StringConcatenation, Style/FormatString
|
|
33
33
|
instance_variables
|
|
34
34
|
.map { |k| k.to_s.sub("@", "") }
|
|
35
35
|
.filter { |k| k != "data" and k != "client" and respond_to? k }
|
|
36
36
|
.map { |k| " #{k}=#{send(k).inspect}" }
|
|
37
|
-
.join("
|
|
37
|
+
.join("\\n") + ">"
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def self.date_accessor(*attrs)
|