@seamapi/nextlove-sdk-generator
Advanced tools
Comparing version 1.13.2 to 1.13.3
import type { SdkGeneratorOptions } from "../../lib/types.js"; | ||
export declare const generatePythonSDK: (options?: SdkGeneratorOptions) => Promise<Record<string, string>>; | ||
export declare function convertCustomResourceNamespace(resource_name: string): string; |
@@ -29,3 +29,4 @@ import { ClassFile } from "./class-file.js"; | ||
const pascal_resource_name = pascalCase(resource_name); | ||
class_map[pascal_resource_name] = new ClassFile(pascal_resource_name, resource_name, child_class_identifiers); | ||
const class_name = pascalCase(convertCustomResourceNamespace(resource_name)); | ||
class_map[pascal_resource_name] = new ClassFile(class_name, resource_name, child_class_identifiers); | ||
}; | ||
@@ -106,3 +107,3 @@ for (const route of routes) { | ||
.map(([schema_name, schema]) => [schema_name, flattenObjSchema(schema)]) | ||
.map(([schema_name, schema]) => resourceDataclassTemplate(pascalCase(schema_name), Object.entries(schema.properties).map(([name, property_schema]) => ({ | ||
.map(([schema_name, schema]) => resourceDataclassTemplate(pascalCase(convertCustomResourceName(schema_name)), Object.entries(schema.properties).map(([name, property_schema]) => ({ | ||
name, | ||
@@ -129,10 +130,18 @@ type: mapPythonType(property_schema), | ||
} | ||
if (response_obj_type) { | ||
return pascalCase(response_obj_type); | ||
const response_type = response_obj_type || response_arr_type; | ||
if (response_type) { | ||
const converted_response_type = convertCustomResourceName(response_type); | ||
const formatted_response_type = pascalCase(converted_response_type); | ||
return response_obj_type | ||
? formatted_response_type | ||
: `List[${formatted_response_type}]`; | ||
} | ||
if (response_arr_type) { | ||
return `List[${pascalCase(response_arr_type)}]`; | ||
} | ||
return "None"; | ||
} | ||
export function convertCustomResourceNamespace(resource_name) { | ||
return resource_name === "events" ? "seam_events" : resource_name; | ||
} | ||
function convertCustomResourceName(response_type) { | ||
return response_type === "event" ? "seam_event" : response_type; | ||
} | ||
//# sourceMappingURL=generate-python-sdk.js.map |
import { pascalCase } from "change-case"; | ||
import { convertCustomResourceNamespace } from "../generate-python-sdk.js"; | ||
export default (namespaces) => [ | ||
@@ -6,8 +7,8 @@ `from typing import Any, Dict`, | ||
`from .models import AbstractRoutes`, | ||
...namespaces.map((ns) => `from .${ns} import ${pascalCase(ns)}`), | ||
...namespaces.map((ns) => `from .${ns} import ${pascalCase(convertCustomResourceNamespace(ns))}`), | ||
``, | ||
`class Routes(AbstractRoutes):`, | ||
` def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):`, | ||
...namespaces.map((ns) => ` self.${ns} = ${pascalCase(ns)}(client=client, defaults=defaults)`), | ||
...namespaces.map((ns) => ` self.${ns} = ${pascalCase(convertCustomResourceNamespace(ns))}(client=client, defaults=defaults)`), | ||
].join("\n"); | ||
//# sourceMappingURL=routes.py.template.js.map |
{ | ||
"name": "@seamapi/nextlove-sdk-generator", | ||
"version": "1.13.2", | ||
"version": "1.13.3", | ||
"description": "Utilities for building NextLove SDK Generators", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -38,5 +38,6 @@ import type { ObjSchema, Route, SdkGeneratorOptions } from "lib/types.js" | ||
const pascal_resource_name = pascalCase(resource_name) | ||
const class_name = pascalCase(convertCustomResourceNamespace(resource_name)) | ||
class_map[pascal_resource_name] = new ClassFile( | ||
pascal_resource_name, | ||
class_name, | ||
resource_name, | ||
@@ -143,3 +144,3 @@ child_class_identifiers | ||
resourceDataclassTemplate( | ||
pascalCase(schema_name), | ||
pascalCase(convertCustomResourceName(schema_name)), | ||
Object.entries(schema.properties).map(([name, property_schema]) => ({ | ||
@@ -183,8 +184,11 @@ name, | ||
if (response_obj_type) { | ||
return pascalCase(response_obj_type) | ||
} | ||
const response_type = response_obj_type || response_arr_type | ||
if (response_arr_type) { | ||
return `List[${pascalCase(response_arr_type)}]` | ||
if (response_type) { | ||
const converted_response_type = convertCustomResourceName(response_type) | ||
const formatted_response_type = pascalCase(converted_response_type) | ||
return response_obj_type | ||
? formatted_response_type | ||
: `List[${formatted_response_type}]` | ||
} | ||
@@ -194,1 +198,9 @@ | ||
} | ||
export function convertCustomResourceNamespace(resource_name: string): string { | ||
return resource_name === "events" ? "seam_events" : resource_name | ||
} | ||
function convertCustomResourceName(response_type: string): string { | ||
return response_type === "event" ? "seam_event" : response_type | ||
} |
import { pascalCase } from "change-case" | ||
import { convertCustomResourceNamespace } from "../generate-python-sdk.js" | ||
export default (namespaces: string[]) => | ||
@@ -7,3 +8,6 @@ [ | ||
`from .models import AbstractRoutes`, | ||
...namespaces.map((ns) => `from .${ns} import ${pascalCase(ns)}`), | ||
...namespaces.map( | ||
(ns) => | ||
`from .${ns} import ${pascalCase(convertCustomResourceNamespace(ns))}` | ||
), | ||
``, | ||
@@ -14,4 +18,6 @@ `class Routes(AbstractRoutes):`, | ||
(ns) => | ||
` self.${ns} = ${pascalCase(ns)}(client=client, defaults=defaults)` | ||
` self.${ns} = ${pascalCase( | ||
convertCustomResourceNamespace(ns) | ||
)}(client=client, defaults=defaults)` | ||
), | ||
].join("\n") |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
652824
8225