simplify sdk

This commit is contained in:
SwiftyOS
2025-07-04 12:20:03 +02:00
parent 5fd15c74bf
commit 7a5c5db56f
19 changed files with 213 additions and 297 deletions

View File

@@ -4,13 +4,9 @@ from backend.sdk import (
BlockCategory,
BlockOutput,
BlockSchema,
Boolean,
CredentialsMetaInput,
Dict,
List,
Requests,
SchemaField,
String,
)
from ._config import exa
@@ -21,21 +17,21 @@ class ExaAnswerBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
query: String = SchemaField(
query: str = SchemaField(
description="The question or query to answer",
placeholder="What is the latest valuation of SpaceX?",
)
stream: Boolean = SchemaField(
stream: bool = SchemaField(
default=False,
description="If true, the response is returned as a server-sent events (SSE) stream",
advanced=True,
)
text: Boolean = SchemaField(
text: bool = SchemaField(
default=False,
description="If true, the response includes full text content in the search results",
advanced=True,
)
model: String = SchemaField(
model: str = SchemaField(
default="exa",
description="The search model to use (exa or exa-pro)",
placeholder="exa",
@@ -43,17 +39,17 @@ class ExaAnswerBlock(Block):
)
class Output(BlockSchema):
answer: String = SchemaField(
answer: str = SchemaField(
description="The generated answer based on search results"
)
citations: List[Dict] = SchemaField(
citations: list[dict] = SchemaField(
description="Search results used to generate the answer",
default_factory=list,
)
cost_dollars: Dict = SchemaField(
cost_dollars: dict = SchemaField(
description="Cost breakdown of the request", default_factory=dict
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)

View File

@@ -5,10 +5,8 @@ from backend.sdk import (
BlockOutput,
BlockSchema,
CredentialsMetaInput,
List,
Requests,
SchemaField,
String,
)
from ._config import exa
@@ -20,7 +18,7 @@ class ExaContentsBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
ids: List[String] = SchemaField(
ids: list[str] = SchemaField(
description="Array of document IDs obtained from searches"
)
contents: ContentSettings = SchemaField(
@@ -30,10 +28,10 @@ class ExaContentsBlock(Block):
)
class Output(BlockSchema):
results: List = SchemaField(
results: list = SchemaField(
description="List of document contents", default_factory=list
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)

View File

@@ -1,13 +1,15 @@
from backend.sdk import BaseModel, Boolean, Integer, List, Optional, SchemaField, String
from typing import Optional
from backend.sdk import BaseModel, SchemaField
class TextSettings(BaseModel):
max_characters: Integer = SchemaField(
max_characters: int = SchemaField(
default=1000,
description="Maximum number of characters to return",
placeholder="1000",
)
include_html_tags: Boolean = SchemaField(
include_html_tags: bool = SchemaField(
default=False,
description="Whether to include HTML tags in the text",
placeholder="False",
@@ -15,12 +17,12 @@ class TextSettings(BaseModel):
class HighlightSettings(BaseModel):
num_sentences: Integer = SchemaField(
num_sentences: int = SchemaField(
default=3,
description="Number of sentences per highlight",
placeholder="3",
)
highlights_per_url: Integer = SchemaField(
highlights_per_url: int = SchemaField(
default=3,
description="Number of highlights per URL",
placeholder="3",
@@ -28,7 +30,7 @@ class HighlightSettings(BaseModel):
class SummarySettings(BaseModel):
query: Optional[String] = SchemaField(
query: Optional[str] = SchemaField(
default="",
description="Query string for summarization",
placeholder="Enter query",
@@ -52,7 +54,7 @@ class ContentSettings(BaseModel):
# Websets Models
class WebsetEntitySettings(BaseModel):
type: Optional[String] = SchemaField(
type: Optional[str] = SchemaField(
default=None,
description="Entity type (e.g., 'company', 'person')",
placeholder="company",
@@ -60,11 +62,11 @@ class WebsetEntitySettings(BaseModel):
class WebsetCriterion(BaseModel):
description: String = SchemaField(
description: str = SchemaField(
description="Description of the criterion",
placeholder="Must be based in the US",
)
success_rate: Optional[Integer] = SchemaField(
success_rate: Optional[int] = SchemaField(
default=None,
description="Success rate percentage",
ge=0,
@@ -73,11 +75,11 @@ class WebsetCriterion(BaseModel):
class WebsetSearchConfig(BaseModel):
query: String = SchemaField(
query: str = SchemaField(
description="Search query",
placeholder="Marketing agencies based in the US",
)
count: Integer = SchemaField(
count: int = SchemaField(
default=10,
description="Number of results to return",
ge=1,
@@ -87,11 +89,11 @@ class WebsetSearchConfig(BaseModel):
default=None,
description="Entity settings for the search",
)
criteria: Optional[List[WebsetCriterion]] = SchemaField(
criteria: Optional[list[WebsetCriterion]] = SchemaField(
default=None,
description="Search criteria",
)
behavior: Optional[String] = SchemaField(
behavior: Optional[str] = SchemaField(
default="override",
description="Behavior when updating results ('override' or 'append')",
placeholder="override",
@@ -99,32 +101,32 @@ class WebsetSearchConfig(BaseModel):
class EnrichmentOption(BaseModel):
label: String = SchemaField(
label: str = SchemaField(
description="Label for the enrichment option",
placeholder="Option 1",
)
class WebsetEnrichmentConfig(BaseModel):
title: String = SchemaField(
title: str = SchemaField(
description="Title of the enrichment",
placeholder="Company Details",
)
description: String = SchemaField(
description: str = SchemaField(
description="Description of what this enrichment does",
placeholder="Extract company information",
)
format: String = SchemaField(
format: str = SchemaField(
default="text",
description="Format of the enrichment result",
placeholder="text",
)
instructions: Optional[String] = SchemaField(
instructions: Optional[str] = SchemaField(
default=None,
description="Instructions for the enrichment",
placeholder="Extract key company metrics",
)
options: Optional[List[EnrichmentOption]] = SchemaField(
options: Optional[list[EnrichmentOption]] = SchemaField(
default=None,
description="Options for the enrichment",
)

View File

@@ -6,13 +6,9 @@ from backend.sdk import (
BlockCategory,
BlockOutput,
BlockSchema,
Boolean,
CredentialsMetaInput,
Integer,
List,
Requests,
SchemaField,
String,
)
from ._config import exa
@@ -24,23 +20,21 @@ class ExaSearchBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
query: String = SchemaField(description="The search query")
use_auto_prompt: Boolean = SchemaField(
query: str = SchemaField(description="The search query")
use_auto_prompt: bool = SchemaField(
description="Whether to use autoprompt", default=True, advanced=True
)
type: String = SchemaField(
description="Type of search", default="", advanced=True
)
category: String = SchemaField(
type: str = SchemaField(description="Type of search", default="", advanced=True)
category: str = SchemaField(
description="Category to search within", default="", advanced=True
)
number_of_results: Integer = SchemaField(
number_of_results: int = SchemaField(
description="Number of results to return", default=10, advanced=True
)
include_domains: List[String] = SchemaField(
include_domains: list[str] = SchemaField(
description="Domains to include in search", default_factory=list
)
exclude_domains: List[String] = SchemaField(
exclude_domains: list[str] = SchemaField(
description="Domains to exclude from search",
default_factory=list,
advanced=True,
@@ -57,10 +51,10 @@ class ExaSearchBlock(Block):
end_published_date: datetime = SchemaField(
description="End date for published content"
)
include_text: List[String] = SchemaField(
include_text: list[str] = SchemaField(
description="Text patterns to include", default_factory=list, advanced=True
)
exclude_text: List[String] = SchemaField(
exclude_text: list[str] = SchemaField(
description="Text patterns to exclude", default_factory=list, advanced=True
)
contents: ContentSettings = SchemaField(
@@ -70,10 +64,10 @@ class ExaSearchBlock(Block):
)
class Output(BlockSchema):
results: List = SchemaField(
results: list = SchemaField(
description="List of search results", default_factory=list
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)

View File

@@ -1,18 +1,15 @@
from datetime import datetime
from typing import Any
from backend.sdk import (
Any,
APIKeyCredentials,
Block,
BlockCategory,
BlockOutput,
BlockSchema,
CredentialsMetaInput,
Integer,
List,
Requests,
SchemaField,
String,
)
from ._config import exa
@@ -24,18 +21,18 @@ class ExaFindSimilarBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
url: String = SchemaField(
url: str = SchemaField(
description="The url for which you would like to find similar links"
)
number_of_results: Integer = SchemaField(
number_of_results: int = SchemaField(
description="Number of results to return", default=10, advanced=True
)
include_domains: List[String] = SchemaField(
include_domains: list[str] = SchemaField(
description="Domains to include in search",
default_factory=list,
advanced=True,
)
exclude_domains: List[String] = SchemaField(
exclude_domains: list[str] = SchemaField(
description="Domains to exclude from search",
default_factory=list,
advanced=True,
@@ -52,12 +49,12 @@ class ExaFindSimilarBlock(Block):
end_published_date: datetime = SchemaField(
description="End date for published content"
)
include_text: List[String] = SchemaField(
include_text: list[str] = SchemaField(
description="Text patterns to include (max 1 string, up to 5 words)",
default_factory=list,
advanced=True,
)
exclude_text: List[String] = SchemaField(
exclude_text: list[str] = SchemaField(
description="Text patterns to exclude (max 1 string, up to 5 words)",
default_factory=list,
advanced=True,
@@ -69,11 +66,11 @@ class ExaFindSimilarBlock(Block):
)
class Output(BlockSchema):
results: List[Any] = SchemaField(
results: list[Any] = SchemaField(
description="List of similar documents with title, URL, published date, author, and score",
default_factory=list,
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)

View File

@@ -1,19 +1,14 @@
from typing import Any, Optional
from backend.sdk import (
Any,
APIKeyCredentials,
Block,
BlockCategory,
BlockOutput,
BlockSchema,
Boolean,
CredentialsMetaInput,
Dict,
Integer,
List,
Optional,
Requests,
SchemaField,
String,
)
from ._config import exa
@@ -28,35 +23,35 @@ class ExaCreateWebsetBlock(Block):
search: WebsetSearchConfig = SchemaField(
description="Initial search configuration for the Webset"
)
enrichments: Optional[List[WebsetEnrichmentConfig]] = SchemaField(
enrichments: Optional[list[WebsetEnrichmentConfig]] = SchemaField(
default=None,
description="Enrichments to apply to Webset items",
advanced=True,
)
external_id: Optional[String] = SchemaField(
external_id: Optional[str] = SchemaField(
default=None,
description="External identifier for the webset",
placeholder="my-webset-123",
advanced=True,
)
metadata: Optional[Dict] = SchemaField(
metadata: Optional[dict] = SchemaField(
default=None,
description="Key-value pairs to associate with this webset",
advanced=True,
)
class Output(BlockSchema):
webset_id: String = SchemaField(
webset_id: str = SchemaField(
description="The unique identifier for the created webset"
)
status: String = SchemaField(description="The status of the webset")
external_id: Optional[String] = SchemaField(
status: str = SchemaField(description="The status of the webset")
external_id: Optional[str] = SchemaField(
description="The external identifier for the webset", default=None
)
created_at: String = SchemaField(
created_at: str = SchemaField(
description="The date and time the webset was created"
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)
@@ -117,30 +112,28 @@ class ExaUpdateWebsetBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
webset_id: String = SchemaField(
webset_id: str = SchemaField(
description="The ID or external ID of the Webset to update",
placeholder="webset-id-or-external-id",
)
metadata: Optional[Dict] = SchemaField(
metadata: Optional[dict] = SchemaField(
default=None,
description="Key-value pairs to associate with this webset (set to null to clear)",
)
class Output(BlockSchema):
webset_id: String = SchemaField(
description="The unique identifier for the webset"
)
status: String = SchemaField(description="The status of the webset")
external_id: Optional[String] = SchemaField(
webset_id: str = SchemaField(description="The unique identifier for the webset")
status: str = SchemaField(description="The status of the webset")
external_id: Optional[str] = SchemaField(
description="The external identifier for the webset", default=None
)
metadata: Dict = SchemaField(
metadata: dict = SchemaField(
description="Updated metadata for the webset", default_factory=dict
)
updated_at: String = SchemaField(
updated_at: str = SchemaField(
description="The date and time the webset was updated"
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)
@@ -190,12 +183,12 @@ class ExaListWebsetsBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
cursor: Optional[String] = SchemaField(
cursor: Optional[str] = SchemaField(
default=None,
description="Cursor for pagination through results",
advanced=True,
)
limit: Integer = SchemaField(
limit: int = SchemaField(
default=25,
description="Number of websets to return (1-100)",
ge=1,
@@ -204,15 +197,15 @@ class ExaListWebsetsBlock(Block):
)
class Output(BlockSchema):
websets: List = SchemaField(description="List of websets", default_factory=list)
has_more: Boolean = SchemaField(
websets: list = SchemaField(description="List of websets", default_factory=list)
has_more: bool = SchemaField(
description="Whether there are more results to paginate through",
default=False,
)
next_cursor: Optional[String] = SchemaField(
next_cursor: Optional[str] = SchemaField(
description="Cursor for the next page of results", default=None
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)
@@ -258,46 +251,44 @@ class ExaGetWebsetBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
webset_id: String = SchemaField(
webset_id: str = SchemaField(
description="The ID or external ID of the Webset to retrieve",
placeholder="webset-id-or-external-id",
)
expand_items: Boolean = SchemaField(
expand_items: bool = SchemaField(
default=False, description="Include items in the response", advanced=True
)
class Output(BlockSchema):
webset_id: String = SchemaField(
description="The unique identifier for the webset"
)
status: String = SchemaField(description="The status of the webset")
external_id: Optional[String] = SchemaField(
webset_id: str = SchemaField(description="The unique identifier for the webset")
status: str = SchemaField(description="The status of the webset")
external_id: Optional[str] = SchemaField(
description="The external identifier for the webset", default=None
)
searches: List[Dict] = SchemaField(
searches: list[dict] = SchemaField(
description="The searches performed on the webset", default_factory=list
)
enrichments: List[Dict] = SchemaField(
enrichments: list[dict] = SchemaField(
description="The enrichments applied to the webset", default_factory=list
)
monitors: List[Dict] = SchemaField(
monitors: list[dict] = SchemaField(
description="The monitors for the webset", default_factory=list
)
items: Optional[List[Dict]] = SchemaField(
items: Optional[list[dict]] = SchemaField(
description="The items in the webset (if expand_items is true)",
default=None,
)
metadata: Dict = SchemaField(
metadata: dict = SchemaField(
description="Key-value pairs associated with the webset",
default_factory=dict,
)
created_at: String = SchemaField(
created_at: str = SchemaField(
description="The date and time the webset was created"
)
updated_at: String = SchemaField(
updated_at: str = SchemaField(
description="The date and time the webset was last updated"
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)
@@ -354,23 +345,23 @@ class ExaDeleteWebsetBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
webset_id: String = SchemaField(
webset_id: str = SchemaField(
description="The ID or external ID of the Webset to delete",
placeholder="webset-id-or-external-id",
)
class Output(BlockSchema):
webset_id: String = SchemaField(
webset_id: str = SchemaField(
description="The unique identifier for the deleted webset"
)
external_id: Optional[String] = SchemaField(
external_id: Optional[str] = SchemaField(
description="The external identifier for the deleted webset", default=None
)
status: String = SchemaField(description="The status of the deleted webset")
success: String = SchemaField(
status: str = SchemaField(description="The status of the deleted webset")
success: str = SchemaField(
description="Whether the deletion was successful", default="true"
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)
@@ -412,25 +403,23 @@ class ExaCancelWebsetBlock(Block):
credentials: CredentialsMetaInput = exa.credentials_field(
description="The Exa integration requires an API Key."
)
webset_id: String = SchemaField(
webset_id: str = SchemaField(
description="The ID or external ID of the Webset to cancel",
placeholder="webset-id-or-external-id",
)
class Output(BlockSchema):
webset_id: String = SchemaField(
description="The unique identifier for the webset"
)
status: String = SchemaField(
webset_id: str = SchemaField(description="The unique identifier for the webset")
status: str = SchemaField(
description="The status of the webset after cancellation"
)
external_id: Optional[String] = SchemaField(
external_id: Optional[str] = SchemaField(
description="The external identifier for the webset", default=None
)
success: String = SchemaField(
success: str = SchemaField(
description="Whether the cancellation was successful", default="true"
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if the request failed", default=""
)

View File

@@ -14,10 +14,8 @@ from backend.sdk import (
BlockCategory,
BlockOutput,
BlockSchema,
Boolean,
CredentialsMetaInput,
SchemaField,
String,
)
from ._config import advanced_service, custom_api
@@ -33,19 +31,19 @@ class AdvancedProviderBlock(Block):
credentials: CredentialsMetaInput = advanced_service.credentials_field(
description="Credentials for Advanced Service",
)
operation: String = SchemaField(
operation: str = SchemaField(
description="Operation to perform",
default="read",
)
data: String = SchemaField(
data: str = SchemaField(
description="Data to process",
default="",
)
class Output(BlockSchema):
result: String = SchemaField(description="Operation result")
auth_type: String = SchemaField(description="Authentication type used")
success: Boolean = SchemaField(description="Whether operation succeeded")
result: str = SchemaField(description="Operation result")
auth_type: str = SchemaField(description="Authentication type used")
success: bool = SchemaField(description="Whether operation succeeded")
def __init__(self):
super().__init__(
@@ -89,18 +87,18 @@ class CustomAPIBlock(Block):
credentials: CredentialsMetaInput = custom_api.credentials_field(
description="Credentials for Custom API",
)
endpoint: String = SchemaField(
endpoint: str = SchemaField(
description="API endpoint to call",
default="/data",
)
payload: String = SchemaField(
payload: str = SchemaField(
description="Payload to send",
default="{}",
)
class Output(BlockSchema):
response: String = SchemaField(description="API response")
status: String = SchemaField(description="Response status")
response: str = SchemaField(description="API response")
status: str = SchemaField(description="Response status")
def __init__(self):
super().__init__(

View File

@@ -11,11 +11,8 @@ from backend.sdk import (
BlockCostType,
BlockOutput,
BlockSchema,
Boolean,
CredentialsMetaInput,
Integer,
SchemaField,
String,
cost,
)
@@ -28,11 +25,11 @@ class FixedCostBlock(Block):
"""Block with a fixed cost per run."""
class Input(BlockSchema):
data: String = SchemaField(description="Input data")
data: str = SchemaField(description="Input data")
class Output(BlockSchema):
result: String = SchemaField(description="Processed data")
cost: Integer = SchemaField(description="Cost in credits")
result: str = SchemaField(description="Processed data")
cost: int = SchemaField(description="Cost in credits")
def __init__(self):
super().__init__(
@@ -70,16 +67,16 @@ class TieredCostBlock(Block):
"""Block with different costs based on selected tier."""
class Input(BlockSchema):
data: String = SchemaField(description="Input data")
tier: String = SchemaField(
data: str = SchemaField(description="Input data")
tier: str = SchemaField(
description="Service tier (basic, standard, or premium)",
default="basic",
)
class Output(BlockSchema):
result: String = SchemaField(description="Processed data")
tier_used: String = SchemaField(description="Service tier used")
cost: Integer = SchemaField(description="Cost in credits")
result: str = SchemaField(description="Processed data")
tier_used: str = SchemaField(description="Service tier used")
cost: int = SchemaField(description="Cost in credits")
def __init__(self):
super().__init__(
@@ -108,11 +105,11 @@ class ProviderCostBlock(Block):
credentials: CredentialsMetaInput = example_service.credentials_field(
description="Example service credentials",
)
data: String = SchemaField(description="Input data")
data: str = SchemaField(description="Input data")
class Output(BlockSchema):
result: String = SchemaField(description="Processed data")
provider_used: String = SchemaField(description="Provider name")
result: str = SchemaField(description="Processed data")
provider_used: str = SchemaField(description="Provider name")
def __init__(self):
super().__init__(
@@ -140,16 +137,16 @@ class DataBasedCostBlock(Block):
"""Block that charges based on data size."""
class Input(BlockSchema):
data: String = SchemaField(description="Input data")
process_intensive: Boolean = SchemaField(
data: str = SchemaField(description="Input data")
process_intensive: bool = SchemaField(
description="Use intensive processing",
default=False,
)
class Output(BlockSchema):
result: String = SchemaField(description="Processed data")
data_size: Integer = SchemaField(description="Data size in bytes")
estimated_cost: String = SchemaField(description="Estimated cost")
result: str = SchemaField(description="Processed data")
data_size: int = SchemaField(description="Data size in bytes")
estimated_cost: str = SchemaField(description="Estimated cost")
def __init__(self):
super().__init__(

View File

@@ -13,11 +13,8 @@ from backend.sdk import (
BlockCategory,
BlockOutput,
BlockSchema,
Boolean,
CredentialsMetaInput,
Integer,
SchemaField,
String,
)
from ._config import (
@@ -44,18 +41,16 @@ class ExampleSDKBlock(Block):
credentials: CredentialsMetaInput = example_service.credentials_field(
description="Credentials for Example Service API",
)
text: String = SchemaField(
description="Text to process", default="Hello, World!"
)
max_length: Integer = SchemaField(
text: str = SchemaField(description="Text to process", default="Hello, World!")
max_length: int = SchemaField(
description="Maximum length of output", default=100
)
class Output(BlockSchema):
result: String = SchemaField(description="Processed text result")
length: Integer = SchemaField(description="Length of the result")
api_key_used: Boolean = SchemaField(description="Whether API key was used")
error: String = SchemaField(description="Error message if any")
result: str = SchemaField(description="Processed text result")
length: int = SchemaField(description="Length of the result")
api_key_used: bool = SchemaField(description="Whether API key was used")
error: str = SchemaField(description="Error message if any")
def __init__(self):
super().__init__(

View File

@@ -17,11 +17,9 @@ from backend.sdk import (
BlockType,
BlockWebhookConfig,
CredentialsMetaInput,
Dict,
Field,
ProviderName,
SchemaField,
String,
)
from ._config import example_webhook
@@ -79,7 +77,7 @@ class ExampleWebhookSDKBlock(Block):
credentials: CredentialsMetaInput = example_webhook.credentials_field(
description="Credentials for webhook service",
)
webhook_url: String = SchemaField(
webhook_url: str = SchemaField(
description="URL to receive webhooks (auto-generated)",
default="",
hidden=True,
@@ -87,15 +85,15 @@ class ExampleWebhookSDKBlock(Block):
event_filter: ExampleEventFilter = SchemaField(
description="Filter for specific events", default=ExampleEventFilter()
)
payload: Dict = SchemaField(
payload: dict = SchemaField(
description="Webhook payload data", default={}, hidden=True
)
class Output(BlockSchema):
event_type: String = SchemaField(description="Type of webhook event")
event_data: Dict = SchemaField(description="Event payload data")
timestamp: String = SchemaField(description="Event timestamp")
error: String = SchemaField(description="Error message if any")
event_type: str = SchemaField(description="Type of webhook event")
event_data: dict = SchemaField(description="Event payload data")
timestamp: str = SchemaField(description="Event timestamp")
error: str = SchemaField(description="Error message if any")
def __init__(self):
super().__init__(

View File

@@ -15,15 +15,7 @@ After SDK: Single import statement
# from pydantic import SecretStr
# === NEW WAY (With SDK) ===
from backend.sdk import (
Block,
BlockCategory,
BlockOutput,
BlockSchema,
Integer,
SchemaField,
String,
)
from backend.sdk import Block, BlockCategory, BlockOutput, BlockSchema, SchemaField
class SimpleExampleBlock(Block):
@@ -36,11 +28,11 @@ class SimpleExampleBlock(Block):
"""
class Input(BlockSchema):
text: String = SchemaField(description="Input text")
count: Integer = SchemaField(description="Number of repetitions", default=1)
text: str = SchemaField(description="Input text")
count: int = SchemaField(description="Number of repetitions", default=1)
class Output(BlockSchema):
result: String = SchemaField(description="Output result")
result: str = SchemaField(description="Output result")
def __init__(self):
super().__init__(

View File

@@ -6,7 +6,6 @@ from backend.sdk import (
CredentialsMetaInput,
OAuth2Credentials,
SchemaField,
String,
)
from ._api import LinearAPIException, LinearClient
@@ -22,15 +21,15 @@ class LinearCreateCommentBlock(Block):
description="Linear credentials with comment creation permissions",
required_scopes={"read", "comments:create"},
)
issue_id: String = SchemaField(description="ID of the issue to comment on")
comment: String = SchemaField(description="Comment text to add to the issue")
issue_id: str = SchemaField(description="ID of the issue to comment on")
comment: str = SchemaField(description="Comment text to add to the issue")
class Output(BlockSchema):
comment_id: String = SchemaField(description="ID of the created comment")
comment_body: String = SchemaField(
comment_id: str = SchemaField(description="ID of the created comment")
comment_body: str = SchemaField(
description="Text content of the created comment"
)
error: String = SchemaField(
error: str = SchemaField(
description="Error message if comment creation failed", default=""
)

View File

@@ -6,7 +6,6 @@ from backend.sdk import (
CredentialsMetaInput,
OAuth2Credentials,
SchemaField,
String,
)
from ._api import LinearAPIException, LinearClient
@@ -22,11 +21,11 @@ class LinearCreateIssueBlock(Block):
description="Linear credentials with issue creation permissions",
required_scopes={"read", "issues:create"},
)
title: String = SchemaField(description="Title of the issue")
description: String = SchemaField(
title: str = SchemaField(description="Title of the issue")
description: str = SchemaField(
description="Description of the issue", default=""
)
team_name: String = SchemaField(
team_name: str = SchemaField(
description="Name of the team to create the issue on"
)
priority: int = SchemaField(
@@ -35,15 +34,15 @@ class LinearCreateIssueBlock(Block):
ge=0,
le=4,
)
project_name: String = SchemaField(
project_name: str = SchemaField(
description="Name of the project to create the issue on",
default="",
)
class Output(BlockSchema):
issue_id: String = SchemaField(description="ID of the created issue")
issue_title: String = SchemaField(description="Title of the created issue")
error: String = SchemaField(
issue_id: str = SchemaField(description="ID of the created issue")
issue_title: str = SchemaField(description="Title of the created issue")
error: str = SchemaField(
description="Error message if issue creation failed", default=""
)
@@ -118,11 +117,11 @@ class LinearSearchIssuesBlock(Block):
description="Linear credentials with read permissions",
required_scopes={"read"},
)
term: String = SchemaField(description="Term to search for issues")
term: str = SchemaField(description="Term to search for issues")
class Output(BlockSchema):
issues: list[Issue] = SchemaField(description="List of issues")
error: String = SchemaField(
error: str = SchemaField(
description="Error message if search failed", default=""
)

View File

@@ -6,7 +6,6 @@ from backend.sdk import (
CredentialsMetaInput,
OAuth2Credentials,
SchemaField,
String,
)
from ._api import LinearAPIException, LinearClient
@@ -22,11 +21,11 @@ class LinearSearchProjectsBlock(Block):
description="Linear credentials with read permissions",
required_scopes={"read"},
)
term: String = SchemaField(description="Term to search for projects")
term: str = SchemaField(description="Term to search for projects")
class Output(BlockSchema):
projects: list[Project] = SchemaField(description="List of projects")
error: String = SchemaField(
error: str = SchemaField(
description="Error message if search failed", default=""
)

View File

@@ -13,14 +13,6 @@ This module provides:
- Auto-registration decorators
"""
# Standard library imports
from typing import Any
from typing import Dict as DictType
from typing import List as ListType
from typing import Literal
from typing import Literal as _Literal
from typing import Optional, Union
# Third-party imports
from pydantic import BaseModel, Field, SecretStr
@@ -115,16 +107,9 @@ except ImportError:
BaseOAuthHandler = None
# === VARIABLE ASSIGNMENTS AND TYPE ALIASES ===
# Type aliases for block development
String = str
Integer = int
Float = float
Boolean = bool
List = ListType
Dict = DictType
# Credential type with proper provider name
from typing import Literal as _Literal
CredentialsMetaInput = _CredentialsMetaInput[
ProviderName, _Literal["api_key", "oauth2", "user_password"]
]
@@ -167,17 +152,6 @@ __all__ = [
"convert",
"TextFormatter",
"TruncatedLogger",
# Type aliases for blocks
"String",
"Integer",
"Float",
"Boolean",
"List",
"Dict",
"Optional",
"Any",
"Union",
"Literal",
"BaseModel",
"Field",
"SecretStr",

View File

@@ -108,7 +108,6 @@ class TestCostIntegration:
BlockSchema,
CredentialsMetaInput,
SchemaField,
String,
cost,
)
@@ -118,10 +117,10 @@ class TestCostIntegration:
credentials: CredentialsMetaInput = example_service.credentials_field(
description="Test credentials"
)
data: String = SchemaField(description="Data")
data: str = SchemaField(description="Data")
class Output(BlockSchema):
result: String = SchemaField(description="Result")
result: str = SchemaField(description="Result")
def __init__(self):
super().__init__(

View File

@@ -5,6 +5,8 @@ This test suite verifies that blocks can be created using only SDK imports
and that they work correctly without decorators.
"""
from typing import Optional
import pytest
from backend.sdk import (
@@ -13,13 +15,9 @@ from backend.sdk import (
BlockCategory,
BlockOutput,
BlockSchema,
Boolean,
CredentialsMetaInput,
Integer,
Optional,
SchemaField,
SecretStr,
String,
)
from ._config import test_api, test_service
@@ -36,11 +34,11 @@ class TestBasicBlockCreation:
"""A simple test block."""
class Input(BlockSchema):
text: String = SchemaField(description="Input text")
count: Integer = SchemaField(description="Repeat count", default=1)
text: str = SchemaField(description="Input text")
count: int = SchemaField(description="Repeat count", default=1)
class Output(BlockSchema):
result: String = SchemaField(description="Output result")
result: str = SchemaField(description="Output result")
def __init__(self):
super().__init__(
@@ -80,11 +78,11 @@ class TestBasicBlockCreation:
credentials: CredentialsMetaInput = test_api.credentials_field(
description="API credentials for test service",
)
query: String = SchemaField(description="API query")
query: str = SchemaField(description="API query")
class Output(BlockSchema):
response: String = SchemaField(description="API response")
authenticated: Boolean = SchemaField(description="Was authenticated")
response: str = SchemaField(description="API response")
authenticated: bool = SchemaField(description="Was authenticated")
def __init__(self):
super().__init__(
@@ -141,13 +139,13 @@ class TestBasicBlockCreation:
"""Block with multiple outputs."""
class Input(BlockSchema):
text: String = SchemaField(description="Input text")
text: str = SchemaField(description="Input text")
class Output(BlockSchema):
uppercase: String = SchemaField(description="Uppercase version")
lowercase: String = SchemaField(description="Lowercase version")
length: Integer = SchemaField(description="Text length")
is_empty: Boolean = SchemaField(description="Is text empty")
uppercase: str = SchemaField(description="Uppercase version")
lowercase: str = SchemaField(description="Lowercase version")
length: int = SchemaField(description="Text length")
is_empty: bool = SchemaField(description="Is text empty")
def __init__(self):
super().__init__(
@@ -192,11 +190,11 @@ class TestBlockWithProvider:
credentials: CredentialsMetaInput = test_service.credentials_field(
description="Test service credentials",
)
action: String = SchemaField(description="Action to perform")
action: str = SchemaField(description="Action to perform")
class Output(BlockSchema):
result: String = SchemaField(description="Action result")
provider_name: String = SchemaField(description="Provider used")
result: str = SchemaField(description="Action result")
provider_name: str = SchemaField(description="Provider used")
def __init__(self):
super().__init__(
@@ -254,22 +252,22 @@ class TestComplexBlockScenarios:
"""Block with optional fields."""
class Input(BlockSchema):
required_field: String = SchemaField(description="Required field")
optional_field: Optional[String] = SchemaField(
required_field: str = SchemaField(description="Required field")
optional_field: Optional[str] = SchemaField(
description="Optional field",
default=None,
)
optional_with_default: String = SchemaField(
optional_with_default: str = SchemaField(
description="Optional with default",
default="default value",
)
class Output(BlockSchema):
has_optional: Boolean = SchemaField(description="Has optional value")
optional_value: Optional[String] = SchemaField(
has_optional: bool = SchemaField(description="Has optional value")
optional_value: Optional[str] = SchemaField(
description="Optional value"
)
default_value: String = SchemaField(description="Default value")
default_value: str = SchemaField(description="Default value")
def __init__(self):
super().__init__(
@@ -316,21 +314,20 @@ class TestComplexBlockScenarios:
@pytest.mark.asyncio
async def test_block_with_complex_types(self):
"""Test block with complex input/output types."""
from backend.sdk import Dict, List
class ComplexBlock(Block):
"""Block with complex types."""
class Input(BlockSchema):
items: List[String] = SchemaField(description="List of items")
mapping: Dict[String, Integer] = SchemaField(
items: list[str] = SchemaField(description="List of items")
mapping: dict[str, int] = SchemaField(
description="String to int mapping"
)
class Output(BlockSchema):
item_count: Integer = SchemaField(description="Number of items")
total_value: Integer = SchemaField(description="Sum of mapping values")
combined: List[String] = SchemaField(description="Combined results")
item_count: int = SchemaField(description="Number of items")
total_value: int = SchemaField(description="Sum of mapping values")
combined: list[str] = SchemaField(description="Combined results")
def __init__(self):
super().__init__(
@@ -376,15 +373,15 @@ class TestComplexBlockScenarios:
"""Block that demonstrates error handling."""
class Input(BlockSchema):
value: Integer = SchemaField(description="Input value")
should_error: Boolean = SchemaField(
value: int = SchemaField(description="Input value")
should_error: bool = SchemaField(
description="Whether to trigger an error",
default=False,
)
class Output(BlockSchema):
result: Integer = SchemaField(description="Result")
error_message: Optional[String] = SchemaField(
result: int = SchemaField(description="Result")
error_message: Optional[str] = SchemaField(
description="Error if any", default=None
)

View File

@@ -438,14 +438,10 @@ class TestSDKImports:
assert APIKeyCredentials is not None
def test_type_alias_imports(self):
"""Test type alias imports."""
from backend.sdk import Boolean, Float, Integer, String
# Verify they're the correct types
assert String is str
assert Integer is int
assert Float is float
assert Boolean is bool
"""Test type alias imports are removed."""
# Type aliases have been removed from SDK
# Users should import from typing or use built-in types directly
pass
def test_cost_system_imports(self):
"""Test cost system imports."""

View File

@@ -19,15 +19,12 @@ from backend.sdk import (
BlockOutput,
BlockSchema,
BlockWebhookConfig,
Boolean,
CredentialsField,
CredentialsMetaInput,
Field,
Integer,
ProviderBuilder,
SchemaField,
SecretStr,
String,
)
@@ -90,10 +87,10 @@ class TestWebhookBlock(Block):
supported_credential_types={"api_key"},
description="Webhook service credentials",
)
webhook_url: String = SchemaField(
webhook_url: str = SchemaField(
description="URL to receive webhooks",
)
resource_id: String = SchemaField(
resource_id: str = SchemaField(
description="Resource to monitor",
)
events: list[TestWebhookTypes] = SchemaField(
@@ -106,9 +103,9 @@ class TestWebhookBlock(Block):
)
class Output(BlockSchema):
webhook_id: String = SchemaField(description="Registered webhook ID")
is_active: Boolean = SchemaField(description="Webhook is active")
event_count: Integer = SchemaField(description="Number of events configured")
webhook_id: str = SchemaField(description="Registered webhook ID")
is_active: bool = SchemaField(description="Webhook is active")
event_count: int = SchemaField(description="Number of events configured")
def __init__(self):
super().__init__(
@@ -207,7 +204,7 @@ class TestWebhookBlockCreation:
provider="test_webhooks",
supported_credential_types={"api_key"},
)
resource: String = SchemaField(description="Resource to monitor")
resource: str = SchemaField(description="Resource to monitor")
filters: EventFilterModel = SchemaField(
description="Event filters",
default_factory=EventFilterModel,
@@ -218,8 +215,8 @@ class TestWebhookBlockCreation:
)
class Output(BlockSchema):
webhook_active: Boolean = SchemaField(description="Webhook active")
filter_summary: String = SchemaField(description="Active filters")
webhook_active: bool = SchemaField(description="Webhook active")
filter_summary: str = SchemaField(description="Active filters")
def __init__(self):
super().__init__(
@@ -357,15 +354,15 @@ class TestWebhookManagerIntegration:
provider="integrated_webhooks",
supported_credential_types={"api_key"},
)
target: String = SchemaField(description="Webhook target")
target: str = SchemaField(description="Webhook target")
payload: dict = SchemaField(
description="Webhook payload",
default={},
)
class Output(BlockSchema):
status: String = SchemaField(description="Webhook status")
manager_type: String = SchemaField(description="Manager type used")
status: str = SchemaField(description="Webhook status")
manager_type: str = SchemaField(description="Manager type used")
def __init__(self):
super().__init__(
@@ -430,17 +427,17 @@ class TestWebhookEventHandling:
"""Block that processes webhook events."""
class Input(BlockSchema):
event_type: String = SchemaField(description="Type of webhook event")
event_type: str = SchemaField(description="Type of webhook event")
payload: dict = SchemaField(description="Webhook payload")
verify_signature: Boolean = SchemaField(
verify_signature: bool = SchemaField(
description="Whether to verify webhook signature",
default=True,
)
class Output(BlockSchema):
processed: Boolean = SchemaField(description="Event was processed")
event_summary: String = SchemaField(description="Summary of event")
action_required: Boolean = SchemaField(description="Action required")
processed: bool = SchemaField(description="Event was processed")
event_summary: str = SchemaField(description="Summary of event")
action_required: bool = SchemaField(description="Action required")
def __init__(self):
super().__init__(