New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@seamapi/nextlove-sdk-generator

Package Overview
Dependencies
Maintainers
5
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@seamapi/nextlove-sdk-generator - npm Package Compare versions

Comparing version 1.10.5 to 1.11.0

lib/generate-python-sdk/templates/abstract-routes.template.d.ts

16

lib/generate-python-sdk/class-file.js

@@ -1,2 +0,2 @@

import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, } from "./templates/utils/action-attempt.js";
import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, action_attempt_error_definitions, } from "./templates/utils/action-attempt.js";
export class ClassFile {

@@ -60,8 +60,9 @@ constructor(name, namespace, child_class_identifiers) {

`Abstract${this.name}`,
`AbstractSeam as Seam`,
...Array.from(new Set(this.methods.map((m) => m.return_resource.replace(/^List\[/, "").replace(/\]$/, "")))),
].filter((classInstance) => classInstance !== "");
const has_child_classes = this.child_class_identifiers.length > 0;
const is_action_attempt_class = this.name === "ActionAttempts";
return [
`from seam.types import (${validClasses
`from seam.types import AbstractSeam as Seam`,
`from seam.routes.types import (${validClasses
.filter((cls) => cls !== "None")

@@ -72,6 +73,9 @@ .join(",")})`,

? this.child_class_identifiers
.map((i) => `from seam.${this.namespace}_${i.namespace} import ${i.class_name}`)
.map((i) => `from seam.routes.${this.namespace}_${i.namespace} import ${i.class_name}`)
.join("\n")
: ""}`,
`${this.name === "ActionAttempts" ? action_attempt_imports : ""}`,
`${is_action_attempt_class ? action_attempt_imports : ""}`,
"",
`${is_action_attempt_class ? action_attempt_error_definitions : ""}`,
"",
`class ${this.name}(Abstract${this.name}):`,

@@ -152,3 +156,3 @@ // TODO DOCSTRING

}),
this.name === "ActionAttempts" ? action_attempt_utils_definitions : "",
is_action_attempt_class ? action_attempt_utils_definitions : "",
].join("\n");

@@ -155,0 +159,0 @@ }

import { ClassFile } from "./class-file.js";
import { pascalCase } from "change-case";
import { flattenObjSchema } from "../../lib/openapi/index.js";
import conftestPyTemplate from "./templates/conftest.py.template.js";
import routesPyTemplate from "./templates/routes.py.template.js";
import seamPyTemplate from "./templates/seam.py.template.js";
import test_smokePyTemplate from "./templates/test_smoke.py.template.js";
import pyprojectTomlTemplate from "./templates/pyproject.toml.template.js";
import { mapPythonType } from "./map-python-type.js";
import deepAttrDictPyTemplate from "./templates/utils/deep_attr_dict.py.template.js";
import actionAttemptsErrorsPyTemplate from "./templates/utils/action_attempt_errors.py.template.js";
import abstractRoutesTemplate from "./templates/snippets/abstract-routes.template.js";
import abstractSeamTemplate from "./templates/snippets/abstract-seam.template.js";
import resourceDataclassTemplate from "./templates/snippets/resource-dataclass.template.js";
import readmeMdTemplate from "./templates/readme.md.template.js";
import initTemplate from "./templates/__init__.py.template.js";
import gitignoreTemplate from "./templates/.gitignore.template.js";
import SeamApiExceptionClassTemplate from "./templates/snippets/seam-api-exception-class.template.js";
import authPyTemplate from "./templates/auth.py.template.js";
import parseOptionsPyTemplate from "./templates/parse_options.py.template.js";
import optionsPyTemplate from "./templates/options.py.template.js";
import tokenPyTemplate from "./templates/token.py.template.js";
import abstractRoutesTemplate from "./templates/abstract-routes.template.js";
import resourceDataclassTemplate from "./templates/resource-dataclass.template.js";
import { getParameterAndResponseSchema } from "../../lib/openapi/get-parameter-and-response-schema.js";

@@ -108,5 +94,5 @@ import mapParentToChildResources from "../../lib/openapi/map-parent-to-children-resource.js";

for (const [_, cls] of Object.entries(class_map)) {
fs[`seam/${cls.namespace}.py`] = cls.serializeToClass();
fs[`seam/routes/${cls.namespace}.py`] = cls.serializeToClass();
}
fs[`seam/types.py`] = [
fs[`seam/routes/types.py`] = [
`from typing import Any, Dict, List, Optional, Union`,

@@ -116,3 +102,3 @@ `from typing_extensions import Self`,

`from dataclasses import dataclass`,
`from seam.utils.deep_attr_dict import DeepAttrDict`,
`from seam.routes.utils.deep_attr_dict import DeepAttrDict`,
"",

@@ -128,5 +114,2 @@ "",

"",
SeamApiExceptionClassTemplate(),
"",
"",
...Object.entries(class_map)

@@ -140,20 +123,5 @@ .sort(

abstractRoutesTemplate(top_level_namespaces),
"",
abstractSeamTemplate(),
].join("\n");
fs["README.md"] = readmeMdTemplate();
fs["pyproject.toml"] = pyprojectTomlTemplate();
fs[".gitignore"] = gitignoreTemplate();
fs["seam/__init__.py"] = initTemplate();
fs["seam/routes.py"] = routesPyTemplate(top_level_namespaces);
fs["seam/seam.py"] = seamPyTemplate();
fs["seam/auth.py"] = authPyTemplate();
fs["seam/token.py"] = tokenPyTemplate();
fs["seam/options.py"] = optionsPyTemplate();
fs["seam/parse_options.py"] = parseOptionsPyTemplate();
fs["seam/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate();
fs["seam/utils/action_attempt_errors.py"] = actionAttemptsErrorsPyTemplate();
fs["tests/conftest.py"] = conftestPyTemplate();
fs["tests/test_smoke.py"] = test_smokePyTemplate();
fs["tests/__init__.py"] = "";
fs["seam/routes/routes.py"] = routesPyTemplate(top_level_namespaces);
fs["seam/routes/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate();
return fs;

@@ -160,0 +128,0 @@ };

@@ -19,2 +19,3 @@ export declare const action_attempt_utils_specs: {

export declare const action_attempt_utils_definitions: string;
export declare const action_attempt_imports = "import time\n\nfrom seam.utils.action_attempt_errors import (\n SeamActionAttemptFailedError,\n SeamActionAttemptTimeoutError,\n)\n";
export declare const action_attempt_imports = "import time\n";
export declare const action_attempt_error_definitions = "class SeamActionAttemptError(Exception):\n def __init__(self, message: str, action_attempt: ActionAttempt):\n super().__init__(message)\n self.name = self.__class__.__name__\n self.action_attempt = action_attempt\n\n\nclass SeamActionAttemptFailedError(SeamActionAttemptError):\n def __init__(self, action_attempt: ActionAttempt):\n super().__init__(action_attempt.error.message, action_attempt)\n self.name = self.__class__.__name__\n self.code = action_attempt.error.type\n\n\nclass SeamActionAttemptTimeoutError(SeamActionAttemptError):\n def __init__(self, action_attempt: ActionAttempt, timeout: str):\n message = f\"Timed out waiting for action attempt after {timeout}s\"\n super().__init__(message, action_attempt)\n self.name = self.__class__.__name__\n";

@@ -70,9 +70,23 @@ export const action_attempt_utils_specs = [

].join("\n");
export const action_attempt_imports = `import time
export const action_attempt_imports = `import time\n`;
export const action_attempt_error_definitions = `class SeamActionAttemptError(Exception):
def __init__(self, message: str, action_attempt: ActionAttempt):
super().__init__(message)
self.name = self.__class__.__name__
self.action_attempt = action_attempt
from seam.utils.action_attempt_errors import (
SeamActionAttemptFailedError,
SeamActionAttemptTimeoutError,
)
class SeamActionAttemptFailedError(SeamActionAttemptError):
def __init__(self, action_attempt: ActionAttempt):
super().__init__(action_attempt.error.message, action_attempt)
self.name = self.__class__.__name__
self.code = action_attempt.error.type
class SeamActionAttemptTimeoutError(SeamActionAttemptError):
def __init__(self, action_attempt: ActionAttempt, timeout: str):
message = f"Timed out waiting for action attempt after {timeout}s"
super().__init__(message, action_attempt)
self.name = self.__class__.__name__
`;
//# sourceMappingURL=action-attempt.js.map
{
"name": "@seamapi/nextlove-sdk-generator",
"version": "1.10.5",
"version": "1.11.0",
"description": "Utilities for building NextLove SDK Generators",

@@ -5,0 +5,0 @@ "type": "module",

@@ -5,2 +5,3 @@ import {

action_attempt_utils_specs,
action_attempt_error_definitions,
} from "./templates/utils/action-attempt.js"

@@ -124,3 +125,2 @@

`Abstract${this.name}`,
`AbstractSeam as Seam`,
...Array.from(

@@ -135,5 +135,7 @@ new Set(

const has_child_classes = this.child_class_identifiers.length > 0
const is_action_attempt_class = this.name === "ActionAttempts"
return [
`from seam.types import (${validClasses
`from seam.types import AbstractSeam as Seam`,
`from seam.routes.types import (${validClasses
.filter((cls) => cls !== "None")

@@ -147,3 +149,3 @@ .join(",")})`,

(i) =>
`from seam.${this.namespace}_${i.namespace} import ${i.class_name}`
`from seam.routes.${this.namespace}_${i.namespace} import ${i.class_name}`
)

@@ -153,4 +155,6 @@ .join("\n")

}`,
`${this.name === "ActionAttempts" ? action_attempt_imports : ""}`,
`${is_action_attempt_class ? action_attempt_imports : ""}`,
"",
`${is_action_attempt_class ? action_attempt_error_definitions : ""}`,
"",
`class ${this.name}(Abstract${this.name}):`,

@@ -265,5 +269,5 @@ // TODO DOCSTRING

),
this.name === "ActionAttempts" ? action_attempt_utils_definitions : "",
is_action_attempt_class ? action_attempt_utils_definitions : "",
].join("\n")
}
}

@@ -5,21 +5,7 @@ import type { ObjSchema, Route, SdkGeneratorOptions } from "lib/types.js"

import { flattenObjSchema } from "lib/openapi/index.js"
import conftestPyTemplate from "./templates/conftest.py.template.js"
import routesPyTemplate from "./templates/routes.py.template.js"
import seamPyTemplate from "./templates/seam.py.template.js"
import test_smokePyTemplate from "./templates/test_smoke.py.template.js"
import pyprojectTomlTemplate from "./templates/pyproject.toml.template.js"
import { mapPythonType } from "./map-python-type.js"
import deepAttrDictPyTemplate from "./templates/utils/deep_attr_dict.py.template.js"
import actionAttemptsErrorsPyTemplate from "./templates/utils/action_attempt_errors.py.template.js"
import abstractRoutesTemplate from "./templates/snippets/abstract-routes.template.js"
import abstractSeamTemplate from "./templates/snippets/abstract-seam.template.js"
import resourceDataclassTemplate from "./templates/snippets/resource-dataclass.template.js"
import readmeMdTemplate from "./templates/readme.md.template.js"
import initTemplate from "./templates/__init__.py.template.js"
import gitignoreTemplate from "./templates/.gitignore.template.js"
import SeamApiExceptionClassTemplate from "./templates/snippets/seam-api-exception-class.template.js"
import authPyTemplate from "./templates/auth.py.template.js"
import parseOptionsPyTemplate from "./templates/parse_options.py.template.js"
import optionsPyTemplate from "./templates/options.py.template.js"
import tokenPyTemplate from "./templates/token.py.template.js"
import abstractRoutesTemplate from "./templates/abstract-routes.template.js"
import resourceDataclassTemplate from "./templates/resource-dataclass.template.js"
import { getParameterAndResponseSchema } from "lib/openapi/get-parameter-and-response-schema.js"

@@ -140,6 +126,6 @@ import mapParentToChildResources from "lib/openapi/map-parent-to-children-resource.js"

for (const [_, cls] of Object.entries(class_map)) {
fs[`seam/${cls.namespace}.py`] = cls.serializeToClass()
fs[`seam/routes/${cls.namespace}.py`] = cls.serializeToClass()
}
fs[`seam/types.py`] = [
fs[`seam/routes/types.py`] = [
`from typing import Any, Dict, List, Optional, Union`,

@@ -149,3 +135,3 @@ `from typing_extensions import Self`,

`from dataclasses import dataclass`,
`from seam.utils.deep_attr_dict import DeepAttrDict`,
`from seam.routes.utils.deep_attr_dict import DeepAttrDict`,
"",

@@ -169,5 +155,2 @@ "",

"",
SeamApiExceptionClassTemplate(),
"",
"",
...Object.entries(class_map)

@@ -183,24 +166,7 @@ .sort(

abstractRoutesTemplate(top_level_namespaces),
"",
abstractSeamTemplate(),
].join("\n")
fs["README.md"] = readmeMdTemplate()
fs["pyproject.toml"] = pyprojectTomlTemplate()
fs[".gitignore"] = gitignoreTemplate()
fs["seam/routes/routes.py"] = routesPyTemplate(top_level_namespaces)
fs["seam/routes/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate()
fs["seam/__init__.py"] = initTemplate()
fs["seam/routes.py"] = routesPyTemplate(top_level_namespaces)
fs["seam/seam.py"] = seamPyTemplate()
fs["seam/auth.py"] = authPyTemplate()
fs["seam/token.py"] = tokenPyTemplate()
fs["seam/options.py"] = optionsPyTemplate()
fs["seam/parse_options.py"] = parseOptionsPyTemplate()
fs["seam/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate()
fs["seam/utils/action_attempt_errors.py"] = actionAttemptsErrorsPyTemplate()
fs["tests/conftest.py"] = conftestPyTemplate()
fs["tests/test_smoke.py"] = test_smokePyTemplate()
fs["tests/__init__.py"] = ""
return fs

@@ -207,0 +173,0 @@ }

@@ -72,8 +72,23 @@ export const action_attempt_utils_specs = [

export const action_attempt_imports = `import time
export const action_attempt_imports = `import time\n`
from seam.utils.action_attempt_errors import (
SeamActionAttemptFailedError,
SeamActionAttemptTimeoutError,
)
export const action_attempt_error_definitions = `class SeamActionAttemptError(Exception):
def __init__(self, message: str, action_attempt: ActionAttempt):
super().__init__(message)
self.name = self.__class__.__name__
self.action_attempt = action_attempt
class SeamActionAttemptFailedError(SeamActionAttemptError):
def __init__(self, action_attempt: ActionAttempt):
super().__init__(action_attempt.error.message, action_attempt)
self.name = self.__class__.__name__
self.code = action_attempt.error.type
class SeamActionAttemptTimeoutError(SeamActionAttemptError):
def __init__(self, action_attempt: ActionAttempt, timeout: str):
message = f"Timed out waiting for action attempt after {timeout}s"
super().__init__(message, action_attempt)
self.name = self.__class__.__name__
`

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc