diff --git a/api/controllers/console/snippets/payloads.py b/api/controllers/console/snippets/payloads.py index 70730e754de..631a35eea32 100644 --- a/api/controllers/console/snippets/payloads.py +++ b/api/controllers/console/snippets/payloads.py @@ -145,6 +145,8 @@ class PublishWorkflowPayload(BaseModel): """Payload for publishing snippet workflow.""" knowledge_base_setting: dict[str, Any] | None = Field(default=None) + marked_name: str | None = Field(default=None, max_length=20) + marked_comment: str | None = Field(default=None, max_length=100) class SnippetImportPayload(BaseModel): diff --git a/api/controllers/console/workspace/snippets.py b/api/controllers/console/workspace/snippets.py index e8f0b228c8b..6e7c79f85ae 100644 --- a/api/controllers/console/workspace/snippets.py +++ b/api/controllers/console/workspace/snippets.py @@ -1,16 +1,13 @@ import logging import re -from typing import Any from urllib.parse import quote from flask import Response, request -from flask_restx import Resource, marshal -from pydantic import RootModel +from flask_restx import Resource from sqlalchemy.orm import Session, sessionmaker from werkzeug.datastructures import MultiDict from werkzeug.exceptions import NotFound -from controllers.common.fields import TextFileResponse from controllers.common.schema import query_params_from_model, register_response_schema_models, register_schema_models from controllers.console import console_ns from controllers.console.snippets.payloads import ( @@ -32,12 +29,13 @@ from controllers.console.wraps import ( ) from extensions.ext_database import db from fields.base import ResponseModel -from fields.snippet_fields import snippet_fields, snippet_list_fields, snippet_pagination_fields +from fields.snippet_fields import SnippetPaginationResponse, SnippetResponse +from libs.helper import dump_response from libs.login import login_required from models import Account from models.snippet import SnippetType from services.app_dsl_service import ImportStatus -from services.snippet_dsl_service import SnippetDslService +from services.snippet_dsl_service import CheckDependenciesResult, SnippetDslService, SnippetImportInfo from services.snippet_service import SnippetService logger = logging.getLogger(__name__) @@ -45,15 +43,7 @@ _TAG_IDS_BRACKET_PATTERN = re.compile(r"^tag_ids\[(\d+)\]$") _CREATOR_IDS_BRACKET_PATTERN = re.compile(r"^creator_ids\[(\d+)\]$") -class SnippetImportResponse(RootModel[dict[str, Any]]): - root: dict[str, Any] - - -class SnippetDependencyCheckResponse(RootModel[dict[str, Any]]): - root: dict[str, Any] - - -class SnippetUseCountResponse(ResponseModel): +class SnippetUseCountIncrementResponse(ResponseModel): result: str use_count: int @@ -100,30 +90,22 @@ register_schema_models( IncludeSecretQuery, ) register_response_schema_models( - console_ns, - TextFileResponse, - SnippetImportResponse, - SnippetDependencyCheckResponse, - SnippetUseCountResponse, + console_ns, SnippetResponse, SnippetPaginationResponse, SnippetUseCountIncrementResponse, SnippetImportInfo ) -# Create namespace models for marshaling -snippet_model = console_ns.model("Snippet", snippet_fields) -snippet_list_model = console_ns.model("SnippetList", snippet_list_fields) -snippet_pagination_model = console_ns.model("SnippetPagination", snippet_pagination_fields) - @console_ns.route("/workspaces/current/customized-snippets") class CustomizedSnippetsApi(Resource): @console_ns.doc("list_customized_snippets") @console_ns.doc(params=query_params_from_model(SnippetListQuery)) - @console_ns.response(200, "Snippets retrieved successfully", snippet_pagination_model) + @console_ns.response(200, "Snippets retrieved successfully", console_ns.models[SnippetPaginationResponse.__name__]) @setup_required @login_required @account_initialization_required @with_current_tenant_id def get(self, current_tenant_id: str): """List customized snippets with pagination and search.""" + query = SnippetListQuery.model_validate(_normalize_snippet_list_query_args(request.args)) snippet_service = _snippet_service() @@ -138,17 +120,20 @@ class CustomizedSnippetsApi(Resource): tag_ids=query.tag_ids, ) - return { - "data": marshal(snippets, snippet_list_fields), - "page": query.page, - "limit": query.limit, - "total": total, - "has_more": has_more, - }, 200 + return dump_response( + SnippetPaginationResponse, + { + "data": snippets, + "page": query.page, + "limit": query.limit, + "total": total, + "has_more": has_more, + }, + ), 200 @console_ns.doc("create_customized_snippet") @console_ns.expect(console_ns.models.get(CreateSnippetPayload.__name__)) - @console_ns.response(201, "Snippet created successfully", snippet_model) + @console_ns.response(201, "Snippet created successfully", console_ns.models[SnippetResponse.__name__]) @console_ns.response(400, "Invalid request") @setup_required @login_required @@ -161,6 +146,7 @@ class CustomizedSnippetsApi(Resource): @with_current_tenant_id def post(self, current_tenant_id: str, current_user: Account): """Create a new customized snippet.""" + payload = CreateSnippetPayload.model_validate(console_ns.payload or {}) try: @@ -185,13 +171,13 @@ class CustomizedSnippetsApi(Resource): except ValueError as e: return {"message": str(e)}, 400 - return marshal(snippet, snippet_fields), 201 + return dump_response(SnippetResponse, snippet), 201 @console_ns.route("/workspaces/current/customized-snippets/") class CustomizedSnippetDetailApi(Resource): @console_ns.doc("get_customized_snippet") - @console_ns.response(200, "Snippet retrieved successfully", snippet_model) + @console_ns.response(200, "Snippet retrieved successfully", console_ns.models[SnippetResponse.__name__]) @console_ns.response(404, "Snippet not found") @setup_required @login_required @@ -199,20 +185,21 @@ class CustomizedSnippetDetailApi(Resource): @with_current_tenant_id def get(self, current_tenant_id: str, snippet_id: str): """Get customized snippet details.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) if not snippet: raise NotFound("Snippet not found") - return marshal(snippet, snippet_fields), 200 + return dump_response(SnippetResponse, snippet), 200 @console_ns.doc("update_customized_snippet") @console_ns.expect(console_ns.models.get(UpdateSnippetPayload.__name__)) - @console_ns.response(200, "Snippet updated successfully", snippet_model) + @console_ns.response(200, "Snippet updated successfully", console_ns.models[SnippetResponse.__name__]) @console_ns.response(400, "Invalid request") @console_ns.response(404, "Snippet not found") @setup_required @@ -226,9 +213,10 @@ class CustomizedSnippetDetailApi(Resource): @with_current_tenant_id def patch(self, current_tenant_id: str, current_user: Account, snippet_id: str): """Update customized snippet.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -257,7 +245,7 @@ class CustomizedSnippetDetailApi(Resource): except ValueError as e: return {"message": str(e)}, 400 - return marshal(snippet, snippet_fields), 200 + return dump_response(SnippetResponse, snippet), 200 @console_ns.doc("delete_customized_snippet") @console_ns.response(204, "Snippet deleted successfully") @@ -270,9 +258,10 @@ class CustomizedSnippetDetailApi(Resource): @with_current_tenant_id def delete(self, current_tenant_id: str, snippet_id: str): """Delete customized snippet.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -296,7 +285,7 @@ class CustomizedSnippetExportApi(Resource): @console_ns.doc(description="Export snippet configuration as DSL") @console_ns.doc(params={"snippet_id": "Snippet ID to export"}) @console_ns.doc(params=query_params_from_model(IncludeSecretQuery)) - @console_ns.response(200, "Snippet exported successfully", console_ns.models[TextFileResponse.__name__]) + @console_ns.response(200, "Snippet exported successfully") @console_ns.response(404, "Snippet not found") @setup_required @login_required @@ -308,9 +297,10 @@ class CustomizedSnippetExportApi(Resource): @with_current_tenant_id def get(self, current_tenant_id: str, snippet_id: str): """Export snippet as DSL.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -343,8 +333,8 @@ class CustomizedSnippetImportApi(Resource): @console_ns.doc("import_customized_snippet") @console_ns.doc(description="Import snippet from DSL") @console_ns.expect(console_ns.models.get(SnippetImportPayload.__name__)) - @console_ns.response(200, "Snippet imported successfully", console_ns.models[SnippetImportResponse.__name__]) - @console_ns.response(202, "Import pending confirmation", console_ns.models[SnippetImportResponse.__name__]) + @console_ns.response(200, "Snippet imported successfully", console_ns.models[SnippetImportInfo.__name__]) + @console_ns.response(202, "Import pending confirmation", console_ns.models[SnippetImportInfo.__name__]) @console_ns.response(400, "Import failed") @setup_required @login_required @@ -385,7 +375,7 @@ class CustomizedSnippetImportConfirmApi(Resource): @console_ns.doc("confirm_snippet_import") @console_ns.doc(description="Confirm a pending snippet import") @console_ns.doc(params={"import_id": "Import ID to confirm"}) - @console_ns.response(200, "Import confirmed successfully", console_ns.models[SnippetImportResponse.__name__]) + @console_ns.response(200, "Import confirmed successfully", console_ns.models[SnippetImportInfo.__name__]) @console_ns.response(400, "Import failed") @setup_required @login_required @@ -412,11 +402,7 @@ class CustomizedSnippetCheckDependenciesApi(Resource): @console_ns.doc("check_snippet_dependencies") @console_ns.doc(description="Check dependencies for a snippet") @console_ns.doc(params={"snippet_id": "Snippet ID"}) - @console_ns.response( - 200, - "Dependencies checked successfully", - console_ns.models[SnippetDependencyCheckResponse.__name__], - ) + @console_ns.response(200, "Dependencies checked successfully", console_ns.models[CheckDependenciesResult.__name__]) @console_ns.response(404, "Snippet not found") @setup_required @login_required @@ -430,7 +416,7 @@ class CustomizedSnippetCheckDependenciesApi(Resource): """Check dependencies for a snippet.""" snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -449,7 +435,11 @@ class CustomizedSnippetUseCountIncrementApi(Resource): @console_ns.doc("increment_snippet_use_count") @console_ns.doc(description="Increment snippet use count by 1") @console_ns.doc(params={"snippet_id": "Snippet ID"}) - @console_ns.response(200, "Use count incremented successfully", console_ns.models[SnippetUseCountResponse.__name__]) + @console_ns.response( + 200, + "Use count incremented successfully", + console_ns.models[SnippetUseCountIncrementResponse.__name__], + ) @console_ns.response(404, "Snippet not found") @setup_required @login_required @@ -461,9 +451,10 @@ class CustomizedSnippetUseCountIncrementApi(Resource): @with_current_tenant_id def post(self, current_tenant_id: str, snippet_id: str): """Increment snippet use count when it is inserted into a workflow.""" + snippet_service = _snippet_service() snippet = snippet_service.get_snippet_by_id( - snippet_id=str(snippet_id), + snippet_id=snippet_id, tenant_id=current_tenant_id, ) @@ -476,4 +467,6 @@ class CustomizedSnippetUseCountIncrementApi(Resource): session.commit() session.refresh(snippet) - return {"result": "success", "use_count": snippet.use_count}, 200 + return SnippetUseCountIncrementResponse(result="success", use_count=snippet.use_count).model_dump( + mode="json" + ), 200 diff --git a/api/fields/member_fields.py b/api/fields/member_fields.py index 9bbcbef8429..80b93f0a24b 100644 --- a/api/fields/member_fields.py +++ b/api/fields/member_fields.py @@ -15,13 +15,13 @@ simple_account_fields = { } -class SimpleAccount(ResponseModel): +class SimpleAccountResponse(ResponseModel): id: str name: str email: str -class _AccountAvatar(ResponseModel): +class _AccountAvatarResponseMixin(ResponseModel): avatar: str | None = None @computed_field(return_type=str | None) # type: ignore[prop-decorator] @@ -30,7 +30,7 @@ class _AccountAvatar(ResponseModel): return build_avatar_url(self.avatar) -class Account(_AccountAvatar): +class AccountResponse(_AccountAvatarResponseMixin): id: str name: str email: str @@ -48,7 +48,7 @@ class Account(_AccountAvatar): return to_timestamp(value) -class AccountWithRole(_AccountAvatar): +class AccountWithRoleResponse(_AccountAvatarResponseMixin): id: str name: str email: str @@ -65,5 +65,11 @@ class AccountWithRole(_AccountAvatar): return to_timestamp(value) -class AccountWithRoleList(ResponseModel): - accounts: list[AccountWithRole] +class AccountWithRoleListResponse(ResponseModel): + accounts: list[AccountWithRoleResponse] + + +SimpleAccount = SimpleAccountResponse +Account = AccountResponse +AccountWithRole = AccountWithRoleResponse +AccountWithRoleList = AccountWithRoleListResponse diff --git a/api/fields/snippet_fields.py b/api/fields/snippet_fields.py index 699a3687ac1..9d12b600722 100644 --- a/api/fields/snippet_fields.py +++ b/api/fields/snippet_fields.py @@ -1,61 +1,67 @@ -from typing import override +from datetime import datetime +from typing import Any -from flask_restx import fields +from pydantic import Field, field_validator -from fields.member_fields import simple_account_fields -from libs.helper import TimestampField +from fields.base import ResponseModel +from fields.member_fields import SimpleAccountResponse +from libs.helper import to_timestamp -class OpaqueRawField(fields.Raw): - @override - def schema(self) -> dict[str, object]: - return {"type": "object"} +class SnippetTagResponse(ResponseModel): + id: str + name: str + type: str -tag_fields = {"id": fields.String, "name": fields.String, "type": fields.String} +class SnippetListItemResponse(ResponseModel): + id: str + name: str + description: str | None = None + type: str + version: int + use_count: int + is_published: bool + icon_info: dict[str, Any] | None = None + tags: list[SnippetTagResponse] = Field(default_factory=list) + created_by: str | None = None + author_name: str | None = None + created_at: int | None = None + updated_by: str | None = None + updated_at: int | None = None -# Snippet list item fields (lightweight for list display) -snippet_list_fields = { - "id": fields.String, - "name": fields.String, - "description": fields.String, - "type": fields.String, - "version": fields.Integer, - "use_count": fields.Integer, - "is_published": fields.Boolean, - "icon_info": OpaqueRawField, - "tags": fields.List(fields.Nested(tag_fields)), - "created_by": fields.String, - "author_name": fields.String, - "created_at": TimestampField, - "updated_by": fields.String, - "updated_at": TimestampField, -} + @field_validator("created_at", "updated_at", mode="before") + @classmethod + def _normalize_timestamp(cls, value: datetime | int | None) -> int | None: + return to_timestamp(value) -# Full snippet fields (includes creator info and graph data) -snippet_fields = { - "id": fields.String, - "name": fields.String, - "description": fields.String, - "type": fields.String, - "version": fields.Integer, - "use_count": fields.Integer, - "is_published": fields.Boolean, - "icon_info": OpaqueRawField, - "graph": OpaqueRawField(attribute="graph_dict"), - "input_fields": OpaqueRawField(attribute="input_fields_list"), - "tags": fields.List(fields.Nested(tag_fields)), - "created_by": fields.Nested(simple_account_fields, attribute="created_by_account", allow_null=True), - "created_at": TimestampField, - "updated_by": fields.Nested(simple_account_fields, attribute="updated_by_account", allow_null=True), - "updated_at": TimestampField, -} -# Pagination response fields -snippet_pagination_fields = { - "data": fields.List(fields.Nested(snippet_list_fields)), - "page": fields.Integer, - "limit": fields.Integer, - "total": fields.Integer, - "has_more": fields.Boolean, -} +class SnippetResponse(ResponseModel): + id: str + name: str + description: str | None = None + type: str + version: int + use_count: int + is_published: bool + icon_info: dict[str, Any] | None = None + graph: dict[str, Any] | None = Field(default=None, validation_alias="graph_dict") + input_fields: list[dict[str, Any]] | None = Field(default=None, validation_alias="input_fields_list") + tags: list[SnippetTagResponse] = Field(default_factory=list) + created_by: SimpleAccountResponse | None = Field(default=None, validation_alias="created_by_account") + created_at: int | None = None + updated_by: SimpleAccountResponse | None = Field(default=None, validation_alias="updated_by_account") + updated_at: int | None = None + + @field_validator("created_at", "updated_at", mode="before") + @classmethod + def _normalize_timestamp(cls, value: datetime | int | None) -> int | None: + return to_timestamp(value) + + +class SnippetPaginationResponse(ResponseModel): + data: list[SnippetListItemResponse] + page: int + limit: int + total: int + has_more: bool diff --git a/api/openapi/markdown/console-openapi.md b/api/openapi/markdown/console-openapi.md index b3a0b8a6a71..12f8a0c54d6 100644 --- a/api/openapi/markdown/console-openapi.md +++ b/api/openapi/markdown/console-openapi.md @@ -38,7 +38,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/change-email #### Request Body @@ -77,7 +77,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/change-email/validity #### Request Body @@ -198,7 +198,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/interface-theme #### Request Body @@ -211,7 +211,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/name #### Request Body @@ -224,7 +224,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/password #### Request Body @@ -237,14 +237,14 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [GET] /account/profile #### Responses | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /account/timezone #### Request Body @@ -257,7 +257,7 @@ Get account avatar url | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [Account](#account)
| +| 200 | Success | **application/json**: [AccountResponse](#accountresponse)
| ### [POST] /activate Activate account with invitation token @@ -9104,7 +9104,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Snippets retrieved successfully | **application/json**: [SnippetPagination](#snippetpagination)
| +| 200 | Snippets retrieved successfully | **application/json**: [SnippetPaginationResponse](#snippetpaginationresponse)
| ### [POST] /workspaces/current/customized-snippets **Create a new customized snippet** @@ -9119,7 +9119,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 201 | Snippet created successfully | **application/json**: [Snippet](#snippet)
| +| 201 | Snippet created successfully | **application/json**: [SnippetResponse](#snippetresponse)
| | 400 | Invalid request | | ### [POST] /workspaces/current/customized-snippets/imports @@ -9135,8 +9135,8 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Snippet imported successfully | **application/json**: [SnippetImportResponse](#snippetimportresponse)
| -| 202 | Import pending confirmation | **application/json**: [SnippetImportResponse](#snippetimportresponse)
| +| 200 | Snippet imported successfully | **application/json**: [SnippetImportInfo](#snippetimportinfo)
| +| 202 | Import pending confirmation | **application/json**: [SnippetImportInfo](#snippetimportinfo)
| | 400 | Import failed | | ### [POST] /workspaces/current/customized-snippets/imports/{import_id}/confirm @@ -9152,7 +9152,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Import confirmed successfully | **application/json**: [SnippetImportResponse](#snippetimportresponse)
| +| 200 | Import confirmed successfully | **application/json**: [SnippetImportInfo](#snippetimportinfo)
| | 400 | Import failed | | ### [DELETE] /workspaces/current/customized-snippets/{snippet_id} @@ -9184,7 +9184,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Snippet retrieved successfully | **application/json**: [Snippet](#snippet)
| +| 200 | Snippet retrieved successfully | **application/json**: [SnippetResponse](#snippetresponse)
| | 404 | Snippet not found | | ### [PATCH] /workspaces/current/customized-snippets/{snippet_id} @@ -9206,7 +9206,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Snippet updated successfully | **application/json**: [Snippet](#snippet)
| +| 200 | Snippet updated successfully | **application/json**: [SnippetResponse](#snippetresponse)
| | 400 | Invalid request | | | 404 | Snippet not found | | @@ -9223,7 +9223,7 @@ Get list of available agent providers | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Dependencies checked successfully | **application/json**: [SnippetDependencyCheckResponse](#snippetdependencycheckresponse)
| +| 200 | Dependencies checked successfully | **application/json**: [CheckDependenciesResult](#checkdependenciesresult)
| | 404 | Snippet not found | | ### [GET] /workspaces/current/customized-snippets/{snippet_id}/export @@ -9240,10 +9240,10 @@ Export snippet configuration as DSL #### Responses -| Code | Description | Schema | -| ---- | ----------- | ------ | -| 200 | Snippet exported successfully | **application/json**: [TextFileResponse](#textfileresponse)
| -| 404 | Snippet not found | | +| Code | Description | +| ---- | ----------- | +| 200 | Snippet exported successfully | +| 404 | Snippet not found | ### [POST] /workspaces/current/customized-snippets/{snippet_id}/use-count/increment **Increment snippet use count when it is inserted into a workflow** @@ -9260,7 +9260,7 @@ Increment snippet use count by 1 | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Use count incremented successfully | **application/json**: [SnippetUseCountResponse](#snippetusecountresponse)
| +| 200 | Use count incremented successfully | **application/json**: [SnippetUseCountIncrementResponse](#snippetusecountincrementresponse)
| | 404 | Snippet not found | | ### [GET] /workspaces/current/dataset-operators @@ -9268,7 +9268,7 @@ Increment snippet use count by 1 | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [AccountWithRoleList](#accountwithrolelist)
| +| 200 | Success | **application/json**: [AccountWithRoleListResponse](#accountwithrolelistresponse)
| ### [GET] /workspaces/current/default-model #### Parameters @@ -9477,7 +9477,7 @@ Update a plugin endpoint | Code | Description | Schema | | ---- | ----------- | ------ | -| 200 | Success | **application/json**: [AccountWithRoleList](#accountwithrolelist)
| +| 200 | Success | **application/json**: [AccountWithRoleListResponse](#accountwithrolelistresponse)
| ### [POST] /workspaces/current/members/invite-email #### Request Body @@ -11928,23 +11928,6 @@ Default namespace | role_name | string | | No | | tenant_id | string | | No | -#### Account - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| avatar | string | | No | -| avatar_url | string | | Yes | -| created_at | integer | | No | -| email | string | | Yes | -| id | string | | Yes | -| interface_language | string | | No | -| interface_theme | string | | No | -| is_password_set | boolean | | Yes | -| last_login_at | integer | | No | -| last_login_ip | string | | No | -| name | string | | Yes | -| timezone | string | | No | - #### AccountAvatarPayload | Name | Type | Description | Required | @@ -12020,13 +12003,36 @@ Default namespace | password | string | | No | | repeat_new_password | string | | Yes | +#### AccountResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| avatar | string | | No | +| avatar_url | string | | Yes | +| created_at | integer | | No | +| email | string | | Yes | +| id | string | | Yes | +| interface_language | string | | No | +| interface_theme | string | | No | +| is_password_set | boolean | | Yes | +| last_login_at | integer | | No | +| last_login_ip | string | | No | +| name | string | | Yes | +| timezone | string | | No | + #### AccountTimezonePayload | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | timezone | string | | Yes | -#### AccountWithRole +#### AccountWithRoleListResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| accounts | [ [AccountWithRoleResponse](#accountwithroleresponse) ] | | Yes | + +#### AccountWithRoleResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | @@ -12041,12 +12047,6 @@ Default namespace | roles | [ object ] | | No | | status | string | | Yes | -#### AccountWithRoleList - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| accounts | [ [AccountWithRole](#accountwithrole) ] | | Yes | - #### ActivateCheckQuery | Name | Type | Description | Required | @@ -12095,7 +12095,7 @@ Default namespace | ---- | ---- | ----------- | -------- | | conversation_id | string | | No | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | elapsed_time | number | | No | | exceptions_count | integer | | No | | finished_at | integer | | No | @@ -18564,6 +18564,8 @@ Payload for publishing snippet workflow. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | knowledge_base_setting | object | | No | +| marked_comment | string | | No | +| marked_name | string | | No | #### PublishedWorkflowRunPayload @@ -19151,6 +19153,14 @@ Model class for provider quota configuration. | id | string | | Yes | | name | string | | Yes | +#### SimpleAccountResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| email | string | | Yes | +| id | string | | Yes | +| name | string | | Yes | + #### SimpleConversation | Name | Type | Description | Required | @@ -19288,32 +19298,6 @@ Validated metadata extracted from a Skill package. | inferable | boolean | | Yes | | reason | string | | No | -#### Snippet - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| created_at | long | | No | -| created_by | [_AnonymousInlineModel_b0fd3f86d9d5](#_anonymousinlinemodel_b0fd3f86d9d5) | | No | -| description | string | | No | -| graph | object | | No | -| icon_info | object | | No | -| id | string | | No | -| input_fields | object | | No | -| is_published | boolean | | No | -| name | string | | No | -| tags | [ [_AnonymousInlineModel_7b8b49ca164e](#_anonymousinlinemodel_7b8b49ca164e) ] | | No | -| type | string | | No | -| updated_at | long | | No | -| updated_by | [_AnonymousInlineModel_b0fd3f86d9d5](#_anonymousinlinemodel_b0fd3f86d9d5) | | No | -| use_count | integer | | No | -| version | integer | | No | - -#### SnippetDependencyCheckResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| SnippetDependencyCheckResponse | object | | | - #### SnippetDraftConfigResponse | Name | Type | Description | Required | @@ -19350,6 +19334,17 @@ Payload for syncing snippet draft workflow. | hash | string | | No | | input_fields | [ object ] | | No | +#### SnippetImportInfo + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| current_dsl_version | string,
**Default:** 0.1.0 | | No | +| error | string | | No | +| id | string | | Yes | +| imported_dsl_version | string | | No | +| snippet_id | string | | No | +| status | [ImportStatus](#importstatus) | | Yes | + #### SnippetImportPayload Payload for importing snippet from DSL. @@ -19363,12 +19358,6 @@ Payload for importing snippet from DSL. | yaml_content | string | YAML content (required for yaml-content mode) | No | | yaml_url | string | YAML URL (required for yaml-url mode) | No | -#### SnippetImportResponse - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| SnippetImportResponse | object | | | - #### SnippetIterationNodeRunPayload Payload for running an iteration node in snippet draft workflow. @@ -19377,24 +19366,24 @@ Payload for running an iteration node in snippet draft workflow. | ---- | ---- | ----------- | -------- | | inputs | object | | No | -#### SnippetList +#### SnippetListItemResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | author_name | string | | No | -| created_at | long | | No | +| created_at | integer | | No | | created_by | string | | No | | description | string | | No | | icon_info | object | | No | -| id | string | | No | -| is_published | boolean | | No | -| name | string | | No | -| tags | [ [_AnonymousInlineModel_7b8b49ca164e](#_anonymousinlinemodel_7b8b49ca164e) ] | | No | -| type | string | | No | -| updated_at | long | | No | +| id | string | | Yes | +| is_published | boolean | | Yes | +| name | string | | Yes | +| tags | [ [SnippetTagResponse](#snippettagresponse) ] | | No | +| type | string | | Yes | +| updated_at | integer | | No | | updated_by | string | | No | -| use_count | integer | | No | -| version | integer | | No | +| use_count | integer | | Yes | +| version | integer | | Yes | #### SnippetListQuery @@ -19417,17 +19406,45 @@ Payload for running a loop node in snippet draft workflow. | ---- | ---- | ----------- | -------- | | inputs | object | | No | -#### SnippetPagination +#### SnippetPaginationResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| data | [ [_AnonymousInlineModel_744ff9cc03e6](#_anonymousinlinemodel_744ff9cc03e6) ] | | No | -| has_more | boolean | | No | -| limit | integer | | No | -| page | integer | | No | -| total | integer | | No | +| data | [ [SnippetListItemResponse](#snippetlistitemresponse) ] | | Yes | +| has_more | boolean | | Yes | +| limit | integer | | Yes | +| page | integer | | Yes | +| total | integer | | Yes | -#### SnippetUseCountResponse +#### SnippetResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| created_at | integer | | No | +| created_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | +| description | string | | No | +| graph | object | | No | +| icon_info | object | | No | +| id | string | | Yes | +| input_fields | [ object ] | | No | +| is_published | boolean | | Yes | +| name | string | | Yes | +| tags | [ [SnippetTagResponse](#snippettagresponse) ] | | No | +| type | string | | Yes | +| updated_at | integer | | No | +| updated_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | +| use_count | integer | | Yes | +| version | integer | | Yes | + +#### SnippetTagResponse + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| id | string | | Yes | +| name | string | | Yes | +| type | string | | Yes | + +#### SnippetUseCountIncrementResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | @@ -19458,7 +19475,7 @@ Query parameters for listing snippet published workflows. | ---- | ---- | ----------- | -------- | | conversation_variables | [ [WorkflowConversationVariableResponse](#workflowconversationvariableresponse) ] | | Yes | | created_at | integer | | Yes | -| created_by | [SimpleAccount](#simpleaccount) | | No | +| created_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | | environment_variables | [ [WorkflowEnvironmentVariableResponse](#workflowenvironmentvariableresponse) ] | | Yes | | features | object | | Yes | | graph | object | | Yes | @@ -19470,7 +19487,7 @@ Query parameters for listing snippet published workflows. | rag_pipeline_variables | [ [PipelineVariableResponse](#pipelinevariableresponse) ] | | Yes | | tool_published | boolean | | Yes | | updated_at | integer | | Yes | -| updated_by | [SimpleAccount](#simpleaccount) | | No | +| updated_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | | version | string | | Yes | #### StarredAppListQuery @@ -20390,7 +20407,7 @@ How a workflow node is bound to an Agent. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | created_by_role | string | | No | | created_from | string | | No | @@ -20427,7 +20444,7 @@ How a workflow node is bound to an Agent. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | id | string | | Yes | | trigger_metadata | | | No | @@ -20528,7 +20545,7 @@ How a workflow node is bound to an Agent. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | -| users | [ [AccountWithRole](#accountwithrole) ] | | Yes | +| users | [ [AccountWithRoleResponse](#accountwithroleresponse) ] | | Yes | #### WorkflowCommentReply @@ -20877,7 +20894,7 @@ can reuse its existing handler. | ---- | ---- | ----------- | -------- | | conversation_variables | [ [WorkflowConversationVariableResponse](#workflowconversationvariableresponse) ] | | Yes | | created_at | integer | | Yes | -| created_by | [SimpleAccount](#simpleaccount) | | No | +| created_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | | environment_variables | [ [WorkflowEnvironmentVariableResponse](#workflowenvironmentvariableresponse) ] | | Yes | | features | object | | Yes | | graph | object | | Yes | @@ -20888,7 +20905,7 @@ can reuse its existing handler. | rag_pipeline_variables | [ [PipelineVariableResponse](#pipelinevariableresponse) ] | | Yes | | tool_published | boolean | | Yes | | updated_at | integer | | Yes | -| updated_by | [SimpleAccount](#simpleaccount) | | No | +| updated_by | [SimpleAccountResponse](#simpleaccountresponse) | | No | | version | string | | Yes | #### WorkflowRestoreResponse @@ -20923,7 +20940,7 @@ can reuse its existing handler. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | created_by_role | string | | No | | elapsed_time | number | | No | @@ -20962,7 +20979,7 @@ can reuse its existing handler. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | elapsed_time | number | | No | | exceptions_count | integer | | No | | finished_at | integer | | No | @@ -21009,7 +21026,7 @@ can reuse its existing handler. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | created_by_role | string | | No | | elapsed_time | number | | No | @@ -21246,41 +21263,6 @@ Workflow tool configuration | data | [ [AccessPolicy](#accesspolicy) ] | | No | | pagination | [Pagination](#pagination) | | No | -#### _AnonymousInlineModel_744ff9cc03e6 - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| author_name | string | | No | -| created_at | long | | No | -| created_by | string | | No | -| description | string | | No | -| icon_info | object | | No | -| id | string | | No | -| is_published | boolean | | No | -| name | string | | No | -| tags | [ [_AnonymousInlineModel_7b8b49ca164e](#_anonymousinlinemodel_7b8b49ca164e) ] | | No | -| type | string | | No | -| updated_at | long | | No | -| updated_by | string | | No | -| use_count | integer | | No | -| version | integer | | No | - -#### _AnonymousInlineModel_7b8b49ca164e - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| id | string | | No | -| name | string | | No | -| type | string | | No | - -#### _AnonymousInlineModel_b0fd3f86d9d5 - -| Name | Type | Description | Required | -| ---- | ---- | ----------- | -------- | -| email | string | | No | -| id | string | | No | -| name | string | | No | - #### _AnonymousInlineModel_b1954337d565 | Name | Type | Description | Required | diff --git a/api/openapi/markdown/service-openapi.md b/api/openapi/markdown/service-openapi.md index 8fc5e75e3cf..5c30aefead1 100644 --- a/api/openapi/markdown/service-openapi.md +++ b/api/openapi/markdown/service-openapi.md @@ -3937,7 +3937,7 @@ Model class for provider with models response. | output_variable_name | string | | Yes | | type | string | | No | -#### SimpleAccount +#### SimpleAccountResponse | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | @@ -4147,7 +4147,7 @@ in form definiton, or a variable while the workflow is running. | Name | Type | Description | Required | | ---- | ---- | ----------- | -------- | | created_at | integer | | No | -| created_by_account | [SimpleAccount](#simpleaccount) | | No | +| created_by_account | [SimpleAccountResponse](#simpleaccountresponse) | | No | | created_by_end_user | [SimpleEndUser](#simpleenduser) | | No | | created_by_role | string | | No | | created_from | string | | No | diff --git a/api/services/snippet_service.py b/api/services/snippet_service.py index 75282db9d4c..803f079c2ce 100644 --- a/api/services/snippet_service.py +++ b/api/services/snippet_service.py @@ -1,6 +1,6 @@ import json import logging -from collections.abc import Iterator, Mapping, Sequence +from collections.abc import Generator, Mapping, Sequence from contextlib import contextmanager from datetime import UTC, datetime from typing import Any @@ -70,7 +70,7 @@ class SnippetService: self._workflow_run_repo = DifyAPIRepositoryFactory.create_api_workflow_run_repository(session_maker) @contextmanager - def _session_scope(self) -> Iterator[Session]: + def _session_scope(self) -> Generator[Session]: current_session = getattr(self, "_session", None) if current_session is not None: yield current_session @@ -627,8 +627,6 @@ class SnippetService: conversation_variables=[], rag_pipeline_variables=draft_workflow.rag_pipeline_variables, kind=WorkflowKind.SNIPPET.value, - marked_name="", - marked_comment="", ) session.add(workflow) diff --git a/api/tests/unit_tests/controllers/console/workspace/test_snippets.py b/api/tests/unit_tests/controllers/console/workspace/test_snippets.py index e8e005a1b83..55eee935606 100644 --- a/api/tests/unit_tests/controllers/console/workspace/test_snippets.py +++ b/api/tests/unit_tests/controllers/console/workspace/test_snippets.py @@ -1,3 +1,4 @@ +from datetime import datetime from inspect import unwrap from types import SimpleNamespace from unittest.mock import ANY, Mock @@ -46,12 +47,73 @@ def _snippet(**overrides) -> CustomizedSnippet: "name": "Snippet", "description": "Description", "type": snippets_module.SnippetType.NODE, + "version": 3, + "use_count": 7, + "is_published": True, + "icon_info": {"icon": "star", "icon_background": "#101828", "icon_type": "emoji"}, + "input_fields": '[{"label": "Question", "variable": "query", "type": "text-input"}]', "created_by": "account-1", + "created_at": datetime(2024, 1, 2, 3, 4, 5), + "updated_by": None, + "updated_at": datetime(2024, 1, 3, 4, 5, 6), } data.update(overrides) return CustomizedSnippet(**data) +def _patch_snippet_response_properties(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr( + CustomizedSnippet, + "tags", + property(lambda _snippet: [{"id": "tag-1", "name": "Search", "type": "snippet"}]), + ) + monkeypatch.setattr(CustomizedSnippet, "created_by_account", property(lambda _snippet: _account("account-1"))) + monkeypatch.setattr(CustomizedSnippet, "updated_by_account", property(lambda _snippet: None)) + + +def _expected_snippet_list_item(snippet: CustomizedSnippet) -> dict: + return { + "id": snippet.id, + "name": snippet.name, + "description": snippet.description, + "type": snippet.type, + "version": snippet.version, + "use_count": snippet.use_count, + "is_published": snippet.is_published, + "icon_info": snippet.icon_info, + "tags": [{"id": "tag-1", "name": "Search", "type": "snippet"}], + "created_by": snippet.created_by, + "author_name": "Test User", + "created_at": int(snippet.created_at.timestamp()), + "updated_by": snippet.updated_by, + "updated_at": int(snippet.updated_at.timestamp()), + } + + +def _expected_snippet_response(snippet: CustomizedSnippet) -> dict: + return { + "id": snippet.id, + "name": snippet.name, + "description": snippet.description, + "type": snippet.type, + "version": snippet.version, + "use_count": snippet.use_count, + "is_published": snippet.is_published, + "icon_info": snippet.icon_info, + "graph": {}, + "input_fields": [{"label": "Question", "variable": "query", "type": "text-input"}], + "tags": [{"id": "tag-1", "name": "Search", "type": "snippet"}], + "created_by": { + "id": "account-1", + "name": "Test User", + "email": "account-1@example.com", + }, + "created_at": int(snippet.created_at.timestamp()), + "updated_by": None, + "updated_at": int(snippet.updated_at.timestamp()), + } + + def test_normalize_snippet_list_query_args_sorts_indexed_values(): query_args = snippets_module.MultiDict( [ @@ -75,7 +137,7 @@ def test_list_snippets_returns_pagination(app: Flask, monkeypatch: pytest.Monkey tag_id = "11111111-1111-1111-1111-111111111111" get_snippets = Mock(return_value=(snippets, 1, False)) monkeypatch.setattr(snippets_module.SnippetService, "get_snippets", get_snippets) - monkeypatch.setattr(snippets_module, "marshal", Mock(return_value=[{"id": "snippet-1"}])) + _patch_snippet_response_properties(monkeypatch) api = snippets_module.CustomizedSnippetsApi() handler = unwrap(api.get) @@ -87,7 +149,7 @@ def test_list_snippets_returns_pagination(app: Flask, monkeypatch: pytest.Monkey assert status_code == 200 assert response == { - "data": [{"id": "snippet-1"}], + "data": [_expected_snippet_list_item(snippets[0])], "page": 2, "limit": 10, "total": 1, @@ -110,6 +172,7 @@ def test_create_snippet_defaults_unknown_type_and_returns_created(app: Flask, mo snippet = _snippet() create_snippet = Mock(return_value=snippet) monkeypatch.setattr(snippets_module.SnippetService, "create_snippet", create_snippet) + _patch_snippet_response_properties(monkeypatch) monkeypatch.setattr( snippets_module.CreateSnippetPayload, "model_validate", @@ -124,7 +187,6 @@ def test_create_snippet_defaults_unknown_type_and_returns_created(app: Flask, mo ) ), ) - monkeypatch.setattr(snippets_module, "marshal", Mock(return_value={"id": "snippet-1"})) api = snippets_module.CustomizedSnippetsApi() handler = unwrap(api.post) @@ -137,7 +199,7 @@ def test_create_snippet_defaults_unknown_type_and_returns_created(app: Flask, mo response, status_code = handler(api, "tenant-1", user) assert status_code == 201 - assert response == {"id": "snippet-1"} + assert response == _expected_snippet_response(snippet) assert create_snippet.call_args.kwargs["snippet_type"] == snippets_module.SnippetType.NODE @@ -184,7 +246,7 @@ def test_get_snippet_detail_raises_when_missing(app: Flask, monkeypatch: pytest. def test_get_snippet_detail_returns_snippet(app: Flask, monkeypatch: pytest.MonkeyPatch): snippet = _snippet() monkeypatch.setattr(snippets_module.SnippetService, "get_snippet_by_id", Mock(return_value=snippet)) - monkeypatch.setattr(snippets_module, "marshal", Mock(return_value={"id": "snippet-1"})) + _patch_snippet_response_properties(monkeypatch) api = snippets_module.CustomizedSnippetDetailApi() handler = unwrap(api.get) @@ -193,7 +255,7 @@ def test_get_snippet_detail_returns_snippet(app: Flask, monkeypatch: pytest.Monk response, status_code = handler(api, "tenant-1", snippet_id="snippet-1") assert status_code == 200 - assert response == {"id": "snippet-1"} + assert response == _expected_snippet_response(snippet) def test_patch_snippet_returns_400_for_empty_payload(app: Flask, monkeypatch: pytest.MonkeyPatch): @@ -230,7 +292,7 @@ def test_patch_snippet_updates_and_commits(app: Flask, monkeypatch: pytest.Monke monkeypatch.setattr(snippets_module.SnippetService, "update_snippet", update_snippet) monkeypatch.setattr(snippets_module, "Session", SessionContext) monkeypatch.setattr(snippets_module, "db", SimpleNamespace(engine=object())) - monkeypatch.setattr(snippets_module, "marshal", Mock(return_value={"id": "snippet-1", "name": "New"})) + _patch_snippet_response_properties(monkeypatch) api = snippets_module.CustomizedSnippetDetailApi() handler = unwrap(api.patch) @@ -243,7 +305,7 @@ def test_patch_snippet_updates_and_commits(app: Flask, monkeypatch: pytest.Monke response, status_code = handler(api, "tenant-1", user, snippet_id="snippet-1") assert status_code == 200 - assert response == {"id": "snippet-1", "name": "New"} + assert response == _expected_snippet_response(updated_snippet) update_snippet.assert_called_once() assert update_snippet.call_args.kwargs["data"] == { "name": "New", diff --git a/api/tests/unit_tests/fields/test_snippet_fields.py b/api/tests/unit_tests/fields/test_snippet_fields.py index ad8ee6e8f0b..233c4e5da90 100644 --- a/api/tests/unit_tests/fields/test_snippet_fields.py +++ b/api/tests/unit_tests/fields/test_snippet_fields.py @@ -1,8 +1,7 @@ from types import SimpleNamespace -from flask_restx import marshal - -from fields.snippet_fields import snippet_list_fields +from fields.snippet_fields import SnippetListItemResponse +from libs.helper import dump_response def test_snippet_list_fields_include_author_name() -> None: @@ -23,6 +22,6 @@ def test_snippet_list_fields_include_author_name() -> None: updated_at=None, ) - result = marshal(snippet, snippet_list_fields) + result = dump_response(SnippetListItemResponse, snippet) assert result["author_name"] == "Alice" diff --git a/packages/contracts/generated/api/console/account/types.gen.ts b/packages/contracts/generated/api/console/account/types.gen.ts index cdd45925fb2..1a7d1644f8f 100644 --- a/packages/contracts/generated/api/console/account/types.gen.ts +++ b/packages/contracts/generated/api/console/account/types.gen.ts @@ -12,7 +12,7 @@ export type AccountAvatarPayload = { avatar: string } -export type Account = { +export type AccountResponse = { avatar?: string | null readonly avatar_url: string | null created_at?: number | null @@ -140,7 +140,7 @@ export type AccountIntegrateResponse = { provider: string } -export type AccountWritable = { +export type AccountResponseWritable = { avatar?: string | null created_at?: number | null email: string @@ -177,7 +177,7 @@ export type PostAccountAvatarData = { } export type PostAccountAvatarResponses = { - 200: Account + 200: AccountResponse } export type PostAccountAvatarResponse = PostAccountAvatarResponses[keyof PostAccountAvatarResponses] @@ -218,7 +218,7 @@ export type PostAccountChangeEmailResetData = { } export type PostAccountChangeEmailResetResponses = { - 200: Account + 200: AccountResponse } export type PostAccountChangeEmailResetResponse @@ -374,7 +374,7 @@ export type PostAccountInterfaceLanguageData = { } export type PostAccountInterfaceLanguageResponses = { - 200: Account + 200: AccountResponse } export type PostAccountInterfaceLanguageResponse @@ -388,7 +388,7 @@ export type PostAccountInterfaceThemeData = { } export type PostAccountInterfaceThemeResponses = { - 200: Account + 200: AccountResponse } export type PostAccountInterfaceThemeResponse @@ -402,7 +402,7 @@ export type PostAccountNameData = { } export type PostAccountNameResponses = { - 200: Account + 200: AccountResponse } export type PostAccountNameResponse = PostAccountNameResponses[keyof PostAccountNameResponses] @@ -415,7 +415,7 @@ export type PostAccountPasswordData = { } export type PostAccountPasswordResponses = { - 200: Account + 200: AccountResponse } export type PostAccountPasswordResponse @@ -429,7 +429,7 @@ export type GetAccountProfileData = { } export type GetAccountProfileResponses = { - 200: Account + 200: AccountResponse } export type GetAccountProfileResponse = GetAccountProfileResponses[keyof GetAccountProfileResponses] @@ -442,7 +442,7 @@ export type PostAccountTimezoneData = { } export type PostAccountTimezoneResponses = { - 200: Account + 200: AccountResponse } export type PostAccountTimezoneResponse diff --git a/packages/contracts/generated/api/console/account/zod.gen.ts b/packages/contracts/generated/api/console/account/zod.gen.ts index 9951efc8d9f..cba539b0316 100644 --- a/packages/contracts/generated/api/console/account/zod.gen.ts +++ b/packages/contracts/generated/api/console/account/zod.gen.ts @@ -17,9 +17,9 @@ export const zAccountAvatarPayload = z.object({ }) /** - * Account + * AccountResponse */ -export const zAccount = z.object({ +export const zAccountResponse = z.object({ avatar: z.string().nullish(), avatar_url: z.string().nullable(), created_at: z.int().nullish(), @@ -212,9 +212,9 @@ export const zAccountIntegrateListResponse = z.object({ }) /** - * Account + * AccountResponse */ -export const zAccountWritable = z.object({ +export const zAccountResponseWritable = z.object({ avatar: z.string().nullish(), created_at: z.int().nullish(), email: z.string(), @@ -242,7 +242,7 @@ export const zPostAccountAvatarBody = zAccountAvatarPayload /** * Success */ -export const zPostAccountAvatarResponse = zAccount +export const zPostAccountAvatarResponse = zAccountResponse export const zPostAccountChangeEmailBody = zChangeEmailSendPayload @@ -263,7 +263,7 @@ export const zPostAccountChangeEmailResetBody = zChangeEmailResetPayload /** * Success */ -export const zPostAccountChangeEmailResetResponse = zAccount +export const zPostAccountChangeEmailResetResponse = zAccountResponse export const zPostAccountChangeEmailValidityBody = zChangeEmailValidityPayload @@ -336,37 +336,37 @@ export const zPostAccountInterfaceLanguageBody = zAccountInterfaceLanguagePayloa /** * Success */ -export const zPostAccountInterfaceLanguageResponse = zAccount +export const zPostAccountInterfaceLanguageResponse = zAccountResponse export const zPostAccountInterfaceThemeBody = zAccountInterfaceThemePayload /** * Success */ -export const zPostAccountInterfaceThemeResponse = zAccount +export const zPostAccountInterfaceThemeResponse = zAccountResponse export const zPostAccountNameBody = zAccountNamePayload /** * Success */ -export const zPostAccountNameResponse = zAccount +export const zPostAccountNameResponse = zAccountResponse export const zPostAccountPasswordBody = zAccountPasswordPayload /** * Success */ -export const zPostAccountPasswordResponse = zAccount +export const zPostAccountPasswordResponse = zAccountResponse /** * Success */ -export const zGetAccountProfileResponse = zAccount +export const zGetAccountProfileResponse = zAccountResponse export const zPostAccountTimezoneBody = zAccountTimezonePayload /** * Success */ -export const zPostAccountTimezoneResponse = zAccount +export const zPostAccountTimezoneResponse = zAccountResponse diff --git a/packages/contracts/generated/api/console/apps/types.gen.ts b/packages/contracts/generated/api/console/apps/types.gen.ts index 9e79518f3cd..d61e8128c14 100644 --- a/packages/contracts/generated/api/console/apps/types.gen.ts +++ b/packages/contracts/generated/api/console/apps/types.gen.ts @@ -731,7 +731,7 @@ export type WorkflowRunPaginationResponse = { export type WorkflowRunDetailResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -799,7 +799,7 @@ export type WorkflowCommentCreate = { } export type WorkflowCommentMentionUsersPayload = { - users: Array + users: Array } export type WorkflowCommentDetail = { @@ -887,7 +887,7 @@ export type DefaultBlockConfigResponse = { export type WorkflowResponse = { conversation_variables: Array created_at: number - created_by?: SimpleAccount | null + created_by?: SimpleAccountResponse | null environment_variables: Array features: { [key: string]: unknown @@ -902,7 +902,7 @@ export type WorkflowResponse = { rag_pipeline_variables: Array tool_published: boolean updated_at: number - updated_by?: SimpleAccount | null + updated_by?: SimpleAccountResponse | null version: string } @@ -1029,7 +1029,7 @@ export type AgentComposerValidateResponse = { export type WorkflowRunNodeExecutionResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -1146,6 +1146,8 @@ export type PublishWorkflowPayload = { knowledge_base_setting?: { [key: string]: unknown } | null + marked_comment?: string | null + marked_name?: string | null } export type WorkflowPublishResponse = { @@ -1289,7 +1291,7 @@ export type WorkflowOnlineUsersByApp = { export type AdvancedChatWorkflowRunForListResponse = { conversation_id?: string | null created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null elapsed_time?: number | null exceptions_count?: number | null finished_at?: number | null @@ -1596,7 +1598,7 @@ export type UserSatisfactionRateStatisticItem = { export type WorkflowAppLogPartialResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null created_from?: string | null @@ -1607,7 +1609,7 @@ export type WorkflowAppLogPartialResponse = { export type WorkflowArchivedLogPartialResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null id: string trigger_metadata?: unknown @@ -1616,7 +1618,7 @@ export type WorkflowArchivedLogPartialResponse = { export type WorkflowRunForListResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null elapsed_time?: number | null exceptions_count?: number | null finished_at?: number | null @@ -1628,7 +1630,7 @@ export type WorkflowRunForListResponse = { version?: string | null } -export type SimpleAccount = { +export type SimpleAccountResponse = { email: string id: string name: string @@ -1671,7 +1673,7 @@ export type WorkflowCommentBasic = { updated_at?: number | null } -export type AccountWithRole = { +export type AccountWithRoleResponse = { avatar?: string | null created_at?: number | null email: string @@ -2054,6 +2056,12 @@ export type SimpleMessageDetail = { query: string } +export type SimpleAccount = { + email: string + id: string + name: string +} + export type HumanInputFormDefinition = { actions?: Array display_in_ui?: boolean diff --git a/packages/contracts/generated/api/console/apps/zod.gen.ts b/packages/contracts/generated/api/console/apps/zod.gen.ts index 9b86fda0a62..19880822bad 100644 --- a/packages/contracts/generated/api/console/apps/zod.gen.ts +++ b/packages/contracts/generated/api/console/apps/zod.gen.ts @@ -728,6 +728,8 @@ export const zWorkflowDraftVariableUpdatePayload = z.object({ */ export const zPublishWorkflowPayload = z.object({ knowledge_base_setting: z.record(z.string(), z.unknown()).nullish(), + marked_comment: z.string().max(100).nullish(), + marked_name: z.string().max(20).nullish(), }) /** @@ -1319,9 +1321,9 @@ export const zUserSatisfactionRateStatisticResponse = z.object({ }) /** - * SimpleAccount + * SimpleAccountResponse */ -export const zSimpleAccount = z.object({ +export const zSimpleAccountResponse = z.object({ email: z.string(), id: z.string(), name: z.string(), @@ -1333,7 +1335,7 @@ export const zSimpleAccount = z.object({ export const zAdvancedChatWorkflowRunForListResponse = z.object({ conversation_id: z.string().nullish(), created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), elapsed_time: z.number().nullish(), exceptions_count: z.int().nullish(), finished_at: z.int().nullish(), @@ -1355,72 +1357,12 @@ export const zAdvancedChatWorkflowRunPaginationResponse = z.object({ limit: z.int(), }) -/** - * ConversationAnnotation - */ -export const zConversationAnnotation = z.object({ - account: zSimpleAccount.nullish(), - content: z.string(), - created_at: z.int().nullish(), - id: z.string(), - question: z.string().nullish(), -}) - -/** - * ConversationAnnotationHitHistory - */ -export const zConversationAnnotationHitHistory = z.object({ - annotation_create_account: zSimpleAccount.nullish(), - created_at: z.int().nullish(), - id: z.string(), -}) - -/** - * Feedback - */ -export const zFeedback = z.object({ - content: z.string().nullish(), - from_account: zSimpleAccount.nullish(), - from_end_user_id: z.string().nullish(), - from_source: z.string(), - rating: z.string(), -}) - -/** - * MessageDetail - */ -export const zMessageDetail = z.object({ - agent_thoughts: z.array(zAgentThought), - annotation: zConversationAnnotation.nullish(), - annotation_hit_history: zConversationAnnotationHitHistory.nullish(), - answer_tokens: z.int(), - conversation_id: z.string(), - created_at: z.int().nullish(), - error: z.string().nullish(), - feedbacks: z.array(zFeedback), - from_account_id: z.string().nullish(), - from_end_user_id: z.string().nullish(), - from_source: z.string(), - id: z.string(), - inputs: z.record(z.string(), zJsonValue), - message: zJsonValue, - message_files: z.array(zMessageFile), - message_metadata_dict: zJsonValue, - message_tokens: z.int(), - parent_message_id: z.string().nullish(), - provider_response_latency: z.number(), - query: z.string(), - re_sign_file_url_answer: z.string(), - status: z.string(), - workflow_run_id: z.string().nullish(), -}) - /** * WorkflowRunForListResponse */ export const zWorkflowRunForListResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), elapsed_time: z.number().nullish(), exceptions_count: z.int().nullish(), finished_at: z.int().nullish(), @@ -1456,7 +1398,7 @@ export const zSimpleEndUser = z.object({ */ export const zWorkflowRunDetailResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), elapsed_time: z.number().nullish(), @@ -1478,7 +1420,7 @@ export const zWorkflowRunDetailResponse = z.object({ */ export const zWorkflowRunNodeExecutionResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), elapsed_time: z.number().nullish(), @@ -1544,9 +1486,9 @@ export const zSandboxUploadResponse = z.object({ }) /** - * AccountWithRole + * AccountWithRoleResponse */ -export const zAccountWithRole = z.object({ +export const zAccountWithRoleResponse = z.object({ avatar: z.string().nullish(), created_at: z.int().nullish(), email: z.string(), @@ -1563,7 +1505,7 @@ export const zAccountWithRole = z.object({ * WorkflowCommentMentionUsersPayload */ export const zWorkflowCommentMentionUsersPayload = z.object({ - users: z.array(zAccountWithRole), + users: z.array(zAccountWithRoleResponse), }) /** @@ -1752,7 +1694,7 @@ export const zPipelineVariableResponse = z.object({ export const zWorkflowResponse = z.object({ conversation_variables: z.array(zWorkflowConversationVariableResponse), created_at: z.int(), - created_by: zSimpleAccount.nullish(), + created_by: zSimpleAccountResponse.nullish(), environment_variables: z.array(zWorkflowEnvironmentVariableResponse), features: z.record(z.string(), z.unknown()), graph: z.record(z.string(), z.unknown()), @@ -1763,7 +1705,7 @@ export const zWorkflowResponse = z.object({ rag_pipeline_variables: z.array(zPipelineVariableResponse), tool_published: z.boolean(), updated_at: z.int(), - updated_by: zSimpleAccount.nullish(), + updated_by: zSimpleAccountResponse.nullish(), version: z.string(), }) @@ -2152,20 +2094,6 @@ export const zConversationDetail = z.object({ user_feedback_stats: zFeedbackStat.nullish(), }) -/** - * ConversationMessageDetail - */ -export const zConversationMessageDetail = z.object({ - created_at: z.int().nullish(), - first_message: zMessageDetail.nullish(), - from_account_id: z.string().nullish(), - from_end_user_id: z.string().nullish(), - from_source: z.string(), - id: z.string(), - model_config: zModelConfig.nullish(), - status: z.string(), -}) - /** * Type */ @@ -2366,6 +2294,26 @@ export const zSimpleMessageDetail = z.object({ query: z.string(), }) +/** + * SimpleAccount + */ +export const zSimpleAccount = z.object({ + email: z.string(), + id: z.string(), + name: z.string(), +}) + +/** + * ConversationAnnotation + */ +export const zConversationAnnotation = z.object({ + account: zSimpleAccount.nullish(), + content: z.string(), + created_at: z.int().nullish(), + id: z.string(), + question: z.string().nullish(), +}) + /** * Conversation */ @@ -2398,6 +2346,69 @@ export const zConversationPagination = z.object({ total: z.int(), }) +/** + * ConversationAnnotationHitHistory + */ +export const zConversationAnnotationHitHistory = z.object({ + annotation_create_account: zSimpleAccount.nullish(), + created_at: z.int().nullish(), + id: z.string(), +}) + +/** + * Feedback + */ +export const zFeedback = z.object({ + content: z.string().nullish(), + from_account: zSimpleAccount.nullish(), + from_end_user_id: z.string().nullish(), + from_source: z.string(), + rating: z.string(), +}) + +/** + * MessageDetail + */ +export const zMessageDetail = z.object({ + agent_thoughts: z.array(zAgentThought), + annotation: zConversationAnnotation.nullish(), + annotation_hit_history: zConversationAnnotationHitHistory.nullish(), + answer_tokens: z.int(), + conversation_id: z.string(), + created_at: z.int().nullish(), + error: z.string().nullish(), + feedbacks: z.array(zFeedback), + from_account_id: z.string().nullish(), + from_end_user_id: z.string().nullish(), + from_source: z.string(), + id: z.string(), + inputs: z.record(z.string(), zJsonValue), + message: zJsonValue, + message_files: z.array(zMessageFile), + message_metadata_dict: zJsonValue, + message_tokens: z.int(), + parent_message_id: z.string().nullish(), + provider_response_latency: z.number(), + query: z.string(), + re_sign_file_url_answer: z.string(), + status: z.string(), + workflow_run_id: z.string().nullish(), +}) + +/** + * ConversationMessageDetail + */ +export const zConversationMessageDetail = z.object({ + created_at: z.int().nullish(), + first_message: zMessageDetail.nullish(), + from_account_id: z.string().nullish(), + from_end_user_id: z.string().nullish(), + from_source: z.string(), + id: z.string(), + model_config: zModelConfig.nullish(), + status: z.string(), +}) + /** * ExecutionContentType */ @@ -2425,7 +2436,7 @@ export const zWorkflowRunForLogResponse = z.object({ */ export const zWorkflowAppLogPartialResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), created_from: z.string().nullish(), @@ -2461,7 +2472,7 @@ export const zWorkflowRunForArchivedLogResponse = z.object({ */ export const zWorkflowArchivedLogPartialResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), id: z.string(), trigger_metadata: z.unknown().optional(), diff --git a/packages/contracts/generated/api/console/rag/types.gen.ts b/packages/contracts/generated/api/console/rag/types.gen.ts index b9862a8d1e8..5a6c903c383 100644 --- a/packages/contracts/generated/api/console/rag/types.gen.ts +++ b/packages/contracts/generated/api/console/rag/types.gen.ts @@ -119,7 +119,7 @@ export type SimpleResultResponse = { export type WorkflowRunDetailResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -158,7 +158,7 @@ export type DefaultBlockConfigResponse = { export type WorkflowResponse = { conversation_variables: Array created_at: number - created_by?: SimpleAccount | null + created_by?: SimpleAccountResponse | null environment_variables: Array features: { [key: string]: unknown @@ -173,7 +173,7 @@ export type WorkflowResponse = { rag_pipeline_variables: Array tool_published: boolean updated_at: number - updated_by?: SimpleAccount | null + updated_by?: SimpleAccountResponse | null version: string } @@ -221,7 +221,7 @@ export type DatasourceVariablesPayload = { export type WorkflowRunNodeExecutionResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -421,7 +421,7 @@ export type PluginDependency = { export type WorkflowRunForListResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null elapsed_time?: number | null exceptions_count?: number | null finished_at?: number | null @@ -433,7 +433,7 @@ export type WorkflowRunForListResponse = { version?: string | null } -export type SimpleAccount = { +export type SimpleAccountResponse = { email: string id: string name: string diff --git a/packages/contracts/generated/api/console/rag/zod.gen.ts b/packages/contracts/generated/api/console/rag/zod.gen.ts index 717db30baa7..5edc412926a 100644 --- a/packages/contracts/generated/api/console/rag/zod.gen.ts +++ b/packages/contracts/generated/api/console/rag/zod.gen.ts @@ -322,9 +322,9 @@ export const zPipelineTemplateListResponse = z.object({ }) /** - * SimpleAccount + * SimpleAccountResponse */ -export const zSimpleAccount = z.object({ +export const zSimpleAccountResponse = z.object({ email: z.string(), id: z.string(), name: z.string(), @@ -335,7 +335,7 @@ export const zSimpleAccount = z.object({ */ export const zWorkflowRunForListResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), elapsed_time: z.number().nullish(), exceptions_count: z.int().nullish(), finished_at: z.int().nullish(), @@ -371,7 +371,7 @@ export const zSimpleEndUser = z.object({ */ export const zWorkflowRunDetailResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), elapsed_time: z.number().nullish(), @@ -393,7 +393,7 @@ export const zWorkflowRunDetailResponse = z.object({ */ export const zWorkflowRunNodeExecutionResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), elapsed_time: z.number().nullish(), @@ -471,7 +471,7 @@ export const zPipelineVariableResponse = z.object({ export const zWorkflowResponse = z.object({ conversation_variables: z.array(zWorkflowConversationVariableResponse), created_at: z.int(), - created_by: zSimpleAccount.nullish(), + created_by: zSimpleAccountResponse.nullish(), environment_variables: z.array(zWorkflowEnvironmentVariableResponse), features: z.record(z.string(), z.unknown()), graph: z.record(z.string(), z.unknown()), @@ -482,7 +482,7 @@ export const zWorkflowResponse = z.object({ rag_pipeline_variables: z.array(zPipelineVariableResponse), tool_published: z.boolean(), updated_at: z.int(), - updated_by: zSimpleAccount.nullish(), + updated_by: zSimpleAccountResponse.nullish(), version: z.string(), }) diff --git a/packages/contracts/generated/api/console/snippets/types.gen.ts b/packages/contracts/generated/api/console/snippets/types.gen.ts index 631da7bace8..c948be32bfb 100644 --- a/packages/contracts/generated/api/console/snippets/types.gen.ts +++ b/packages/contracts/generated/api/console/snippets/types.gen.ts @@ -16,7 +16,7 @@ export type SimpleResultResponse = { export type WorkflowRunDetailResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -51,7 +51,7 @@ export type DefaultBlockConfigsResponse = Array<{ export type SnippetWorkflowResponse = { conversation_variables: Array created_at: number - created_by?: SimpleAccount | null + created_by?: SimpleAccountResponse | null environment_variables: Array features: { [key: string]: unknown @@ -69,7 +69,7 @@ export type SnippetWorkflowResponse = { rag_pipeline_variables: Array tool_published: boolean updated_at: number - updated_by?: SimpleAccount | null + updated_by?: SimpleAccountResponse | null version: string } @@ -120,7 +120,7 @@ export type SnippetLoopNodeRunPayload = { export type WorkflowRunNodeExecutionResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null elapsed_time?: number | null @@ -201,6 +201,8 @@ export type PublishWorkflowPayload = { knowledge_base_setting?: { [key: string]: unknown } | null + marked_comment?: string | null + marked_name?: string | null } export type WorkflowPublishResponse = { @@ -210,7 +212,7 @@ export type WorkflowPublishResponse = { export type WorkflowRunForListResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null elapsed_time?: number | null exceptions_count?: number | null finished_at?: number | null @@ -222,7 +224,7 @@ export type WorkflowRunForListResponse = { version?: string | null } -export type SimpleAccount = { +export type SimpleAccountResponse = { email: string id: string name: string diff --git a/packages/contracts/generated/api/console/snippets/zod.gen.ts b/packages/contracts/generated/api/console/snippets/zod.gen.ts index 85e5b961547..1478841c355 100644 --- a/packages/contracts/generated/api/console/snippets/zod.gen.ts +++ b/packages/contracts/generated/api/console/snippets/zod.gen.ts @@ -123,6 +123,8 @@ export const zWorkflowDraftVariableUpdatePayload = z.object({ */ export const zPublishWorkflowPayload = z.object({ knowledge_base_setting: z.record(z.string(), z.unknown()).nullish(), + marked_comment: z.string().max(100).nullish(), + marked_name: z.string().max(20).nullish(), }) /** @@ -134,9 +136,9 @@ export const zWorkflowPublishResponse = z.object({ }) /** - * SimpleAccount + * SimpleAccountResponse */ -export const zSimpleAccount = z.object({ +export const zSimpleAccountResponse = z.object({ email: z.string(), id: z.string(), name: z.string(), @@ -147,7 +149,7 @@ export const zSimpleAccount = z.object({ */ export const zWorkflowRunForListResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), elapsed_time: z.number().nullish(), exceptions_count: z.int().nullish(), finished_at: z.int().nullish(), @@ -183,7 +185,7 @@ export const zSimpleEndUser = z.object({ */ export const zWorkflowRunDetailResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), elapsed_time: z.number().nullish(), @@ -205,7 +207,7 @@ export const zWorkflowRunDetailResponse = z.object({ */ export const zWorkflowRunNodeExecutionResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), elapsed_time: z.number().nullish(), @@ -283,7 +285,7 @@ export const zPipelineVariableResponse = z.object({ export const zSnippetWorkflowResponse = z.object({ conversation_variables: z.array(zWorkflowConversationVariableResponse), created_at: z.int(), - created_by: zSimpleAccount.nullish(), + created_by: zSimpleAccountResponse.nullish(), environment_variables: z.array(zWorkflowEnvironmentVariableResponse), features: z.record(z.string(), z.unknown()), graph: z.record(z.string(), z.unknown()), @@ -295,7 +297,7 @@ export const zSnippetWorkflowResponse = z.object({ rag_pipeline_variables: z.array(zPipelineVariableResponse), tool_published: z.boolean(), updated_at: z.int(), - updated_by: zSimpleAccount.nullish(), + updated_by: zSimpleAccountResponse.nullish(), version: z.string(), }) diff --git a/packages/contracts/generated/api/console/workspaces/orpc.gen.ts b/packages/contracts/generated/api/console/workspaces/orpc.gen.ts index 7e676564999..4b58de10c4e 100644 --- a/packages/contracts/generated/api/console/workspaces/orpc.gen.ts +++ b/packages/contracts/generated/api/console/workspaces/orpc.gen.ts @@ -40,9 +40,6 @@ import { zGetWorkspacesCurrentAgentProvidersResponse, zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesPath, zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponse, - zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportPath, - zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportQuery, - zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse, zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdPath, zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse, zGetWorkspacesCurrentCustomizedSnippetsQuery, @@ -524,33 +521,6 @@ export const checkDependencies = { get: get3, } -/** - * Export snippet as DSL - * - * Export snippet configuration as DSL - */ -export const get4 = oc - .route({ - description: 'Export snippet configuration as DSL', - inputStructure: 'detailed', - method: 'GET', - operationId: 'getWorkspacesCurrentCustomizedSnippetsBySnippetIdExport', - path: '/workspaces/current/customized-snippets/{snippet_id}/export', - summary: 'Export snippet as DSL', - tags: ['console'], - }) - .input( - z.object({ - params: zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportPath, - query: zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportQuery.optional(), - }), - ) - .output(zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse) - -export const export_ = { - get: get4, -} - /** * Increment snippet use count when it is inserted into a workflow * @@ -598,7 +568,7 @@ export const delete_ = oc /** * Get customized snippet details */ -export const get5 = oc +export const get4 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -632,17 +602,16 @@ export const patch = oc export const bySnippetId = { delete: delete_, - get: get5, + get: get4, patch, checkDependencies, - export: export_, useCount, } /** * List customized snippets with pagination and search */ -export const get6 = oc +export const get5 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -671,13 +640,13 @@ export const post4 = oc .output(zPostWorkspacesCurrentCustomizedSnippetsResponse) export const customizedSnippets = { - get: get6, + get: get5, post: post4, imports, bySnippetId, } -export const get7 = oc +export const get6 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -688,10 +657,10 @@ export const get7 = oc .output(zGetWorkspacesCurrentDatasetOperatorsResponse) export const datasetOperators = { - get: get7, + get: get6, } -export const get8 = oc +export const get7 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -714,7 +683,7 @@ export const post5 = oc .output(zPostWorkspacesCurrentDefaultModelResponse) export const defaultModel = { - get: get8, + get: get7, post: post5, } @@ -805,7 +774,7 @@ export const enable = { /** * List endpoints for a specific plugin */ -export const get9 = oc +export const get8 = oc .route({ description: 'List endpoints for a specific plugin', inputStructure: 'detailed', @@ -818,13 +787,13 @@ export const get9 = oc .output(zGetWorkspacesCurrentEndpointsListPluginResponse) export const plugin = { - get: get9, + get: get8, } /** * List plugin endpoints with pagination */ -export const get10 = oc +export const get9 = oc .route({ description: 'List plugin endpoints with pagination', inputStructure: 'detailed', @@ -837,7 +806,7 @@ export const get10 = oc .output(zGetWorkspacesCurrentEndpointsListResponse) export const list = { - get: get10, + get: get9, plugin, } @@ -1033,7 +1002,7 @@ export const byMemberId = { updateRole, } -export const get11 = oc +export const get10 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1044,14 +1013,14 @@ export const get11 = oc .output(zGetWorkspacesCurrentMembersResponse) export const members = { - get: get11, + get: get10, inviteEmail, ownerTransferCheck, sendOwnerTransferConfirmEmail, byMemberId, } -export const get12 = oc +export const get11 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1063,7 +1032,7 @@ export const get12 = oc .output(zGetWorkspacesCurrentModelProvidersByProviderCheckoutUrlResponse) export const checkoutUrl = { - get: get12, + get: get11, } export const post16 = oc @@ -1123,7 +1092,7 @@ export const delete5 = oc ) .output(zDeleteWorkspacesCurrentModelProvidersByProviderCredentialsResponse) -export const get13 = oc +export const get12 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1174,7 +1143,7 @@ export const put2 = oc export const credentials = { delete: delete5, - get: get13, + get: get12, post: post18, put: put2, switch: switch_, @@ -1238,7 +1207,7 @@ export const delete6 = oc ) .output(zDeleteWorkspacesCurrentModelProvidersByProviderModelsCredentialsResponse) -export const get14 = oc +export const get13 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1289,7 +1258,7 @@ export const put3 = oc export const credentials2 = { delete: delete6, - get: get14, + get: get13, post: post21, put: put3, switch: switch2, @@ -1393,7 +1362,7 @@ export const loadBalancingConfigs = { byConfigId, } -export const get15 = oc +export const get14 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1410,7 +1379,7 @@ export const get15 = oc .output(zGetWorkspacesCurrentModelProvidersByProviderModelsParameterRulesResponse) export const parameterRules = { - get: get15, + get: get14, } export const delete7 = oc @@ -1430,7 +1399,7 @@ export const delete7 = oc ) .output(zDeleteWorkspacesCurrentModelProvidersByProviderModelsResponse) -export const get16 = oc +export const get15 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1459,7 +1428,7 @@ export const post24 = oc export const models = { delete: delete7, - get: get16, + get: get15, post: post24, credentials: credentials2, disable: disable2, @@ -1495,7 +1464,7 @@ export const byProvider = { preferredProviderType, } -export const get17 = oc +export const get16 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1507,11 +1476,11 @@ export const get17 = oc .output(zGetWorkspacesCurrentModelProvidersResponse) export const modelProviders = { - get: get17, + get: get16, byProvider, } -export const get18 = oc +export const get17 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1523,7 +1492,7 @@ export const get18 = oc .output(zGetWorkspacesCurrentModelsModelTypesByModelTypeResponse) export const byModelType = { - get: get18, + get: get17, } export const modelTypes = { @@ -1539,7 +1508,7 @@ export const models2 = { * * Returns permission flags that control workspace features like member invitations and owner transfer. */ -export const get19 = oc +export const get18 = oc .route({ description: 'Returns permission flags that control workspace features like member invitations and owner transfer.', @@ -1553,10 +1522,10 @@ export const get19 = oc .output(zGetWorkspacesCurrentPermissionResponse) export const permission = { - get: get19, + get: get18, } -export const get20 = oc +export const get19 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1568,7 +1537,7 @@ export const get20 = oc .output(zGetWorkspacesCurrentPluginAssetResponse) export const asset = { - get: get20, + get: get19, } export const post26 = oc @@ -1601,7 +1570,7 @@ export const exclude = { post: post27, } -export const get21 = oc +export const get20 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1613,7 +1582,7 @@ export const get21 = oc .output(zGetWorkspacesCurrentPluginAutoUpgradeFetchResponse) export const fetch_ = { - get: get21, + get: get20, } export const autoUpgrade = { @@ -1622,7 +1591,7 @@ export const autoUpgrade = { fetch: fetch_, } -export const get22 = oc +export const get21 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1633,10 +1602,10 @@ export const get22 = oc .output(zGetWorkspacesCurrentPluginDebuggingKeyResponse) export const debuggingKey = { - get: get22, + get: get21, } -export const get23 = oc +export const get22 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1648,10 +1617,10 @@ export const get23 = oc .output(zGetWorkspacesCurrentPluginFetchManifestResponse) export const fetchManifest = { - get: get23, + get: get22, } -export const get24 = oc +export const get23 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1663,7 +1632,7 @@ export const get24 = oc .output(zGetWorkspacesCurrentPluginIconResponse) export const icon = { - get: get24, + get: get23, } export const post28 = oc @@ -1751,7 +1720,7 @@ export const latestVersions = { post: post32, } -export const get25 = oc +export const get24 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1763,12 +1732,12 @@ export const get25 = oc .output(zGetWorkspacesCurrentPluginListResponse) export const list2 = { - get: get25, + get: get24, installations, latestVersions, } -export const get26 = oc +export const get25 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1780,14 +1749,14 @@ export const get26 = oc .output(zGetWorkspacesCurrentPluginMarketplacePkgResponse) export const pkg2 = { - get: get26, + get: get25, } export const marketplace2 = { pkg: pkg2, } -export const get27 = oc +export const get26 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1799,7 +1768,7 @@ export const get27 = oc .output(zGetWorkspacesCurrentPluginParametersDynamicOptionsResponse) export const dynamicOptions = { - get: get27, + get: get26, } /** @@ -1843,7 +1812,7 @@ export const change2 = { post: post34, } -export const get28 = oc +export const get27 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1854,7 +1823,7 @@ export const get28 = oc .output(zGetWorkspacesCurrentPluginPermissionFetchResponse) export const fetch2 = { - get: get28, + get: get27, } export const permission2 = { @@ -1862,7 +1831,7 @@ export const permission2 = { fetch: fetch2, } -export const get29 = oc +export const get28 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1874,7 +1843,7 @@ export const get29 = oc .output(zGetWorkspacesCurrentPluginReadmeResponse) export const readme = { - get: get29, + get: get28, } export const post35 = oc @@ -1922,7 +1891,7 @@ export const delete8 = { byIdentifier, } -export const get30 = oc +export const get29 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1934,11 +1903,11 @@ export const get30 = oc .output(zGetWorkspacesCurrentPluginTasksByTaskIdResponse) export const byTaskId = { - get: get30, + get: get29, delete: delete8, } -export const get31 = oc +export const get30 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -1950,7 +1919,7 @@ export const get31 = oc .output(zGetWorkspacesCurrentPluginTasksResponse) export const tasks = { - get: get31, + get: get30, deleteAll, byTaskId, } @@ -2054,7 +2023,7 @@ export const upload = { pkg: pkg3, } -export const get32 = oc +export const get31 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2071,7 +2040,7 @@ export const get32 = oc .output(zGetWorkspacesCurrentPluginByCategoryListResponse) export const list3 = { - get: get32, + get: get31, } export const byCategory = { @@ -2124,7 +2093,7 @@ export const delete9 = oc .input(z.object({ params: zDeleteWorkspacesCurrentRbacAccessPoliciesByPolicyIdPath })) .output(zDeleteWorkspacesCurrentRbacAccessPoliciesByPolicyIdResponse) -export const get33 = oc +export const get32 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2148,12 +2117,12 @@ export const put4 = oc export const byPolicyId = { delete: delete9, - get: get33, + get: get32, put: put4, copy, } -export const get34 = oc +export const get33 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2175,7 +2144,7 @@ export const post45 = oc .output(zPostWorkspacesCurrentRbacAccessPoliciesResponse) export const accessPolicies = { - get: get34, + get: get33, post: post45, byPolicyId, } @@ -2234,7 +2203,7 @@ export const delete10 = oc ) .output(zDeleteWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdMemberBindingsResponse) -export const get35 = oc +export const get34 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2251,10 +2220,10 @@ export const get35 = oc export const memberBindings = { delete: delete10, - get: get35, + get: get34, } -export const get36 = oc +export const get35 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2270,7 +2239,7 @@ export const get36 = oc .output(zGetWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdRoleBindingsResponse) export const roleBindings = { - get: get36, + get: get35, } export const byPolicyId2 = { @@ -2282,7 +2251,7 @@ export const accessPolicies2 = { byPolicyId: byPolicyId2, } -export const get37 = oc +export const get36 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2294,10 +2263,10 @@ export const get37 = oc .output(zGetWorkspacesCurrentRbacAppsByAppIdAccessPolicyResponse) export const accessPolicy = { - get: get37, + get: get36, } -export const get38 = oc +export const get37 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2309,7 +2278,7 @@ export const get38 = oc .output(zGetWorkspacesCurrentRbacAppsByAppIdUserAccessPoliciesResponse) export const userAccessPolicies = { - get: get38, + get: get37, } export const put7 = oc @@ -2339,7 +2308,7 @@ export const users = { byTargetAccountId, } -export const get39 = oc +export const get38 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2362,7 +2331,7 @@ export const put8 = oc .output(zPutWorkspacesCurrentRbacAppsByAppIdWhitelistResponse) export const whitelist = { - get: get39, + get: get38, put: put8, } @@ -2397,7 +2366,7 @@ export const delete11 = oc zDeleteWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdMemberBindingsResponse, ) -export const get40 = oc +export const get39 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2418,10 +2387,10 @@ export const get40 = oc export const memberBindings2 = { delete: delete11, - get: get40, + get: get39, } -export const get41 = oc +export const get40 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2437,7 +2406,7 @@ export const get41 = oc .output(zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdRoleBindingsResponse) export const roleBindings2 = { - get: get41, + get: get40, } export const byPolicyId3 = { @@ -2449,7 +2418,7 @@ export const accessPolicies4 = { byPolicyId: byPolicyId3, } -export const get42 = oc +export const get41 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2461,10 +2430,10 @@ export const get42 = oc .output(zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPolicyResponse) export const accessPolicy2 = { - get: get42, + get: get41, } -export const get43 = oc +export const get42 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2476,7 +2445,7 @@ export const get43 = oc .output(zGetWorkspacesCurrentRbacDatasetsByDatasetIdUserAccessPoliciesResponse) export const userAccessPolicies2 = { - get: get43, + get: get42, } export const put9 = oc @@ -2506,7 +2475,7 @@ export const users2 = { byTargetAccountId: byTargetAccountId2, } -export const get44 = oc +export const get43 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2529,7 +2498,7 @@ export const put10 = oc .output(zPutWorkspacesCurrentRbacDatasetsByDatasetIdWhitelistResponse) export const whitelist2 = { - get: get44, + get: get43, put: put10, } @@ -2545,7 +2514,7 @@ export const datasets = { byDatasetId, } -export const get45 = oc +export const get44 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2568,7 +2537,7 @@ export const put11 = oc .output(zPutWorkspacesCurrentRbacMembersByMemberIdRbacRolesResponse) export const rbacRoles = { - get: get45, + get: get44, put: put11, } @@ -2580,7 +2549,7 @@ export const members2 = { byMemberId: byMemberId2, } -export const get46 = oc +export const get45 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2591,10 +2560,10 @@ export const get46 = oc .output(zGetWorkspacesCurrentRbacMyPermissionsResponse) export const myPermissions = { - get: get46, + get: get45, } -export const get47 = oc +export const get46 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2605,10 +2574,10 @@ export const get47 = oc .output(zGetWorkspacesCurrentRbacRolePermissionsCatalogAppResponse) export const app = { - get: get47, + get: get46, } -export const get48 = oc +export const get47 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2619,10 +2588,10 @@ export const get48 = oc .output(zGetWorkspacesCurrentRbacRolePermissionsCatalogDatasetResponse) export const dataset = { - get: get48, + get: get47, } -export const get49 = oc +export const get48 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2633,7 +2602,7 @@ export const get49 = oc .output(zGetWorkspacesCurrentRbacRolePermissionsCatalogResponse) export const catalog = { - get: get49, + get: get48, app, dataset, } @@ -2658,7 +2627,7 @@ export const copy2 = { post: post46, } -export const get50 = oc +export const get49 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2670,7 +2639,7 @@ export const get50 = oc .output(zGetWorkspacesCurrentRbacRolesByRoleIdMembersResponse) export const members3 = { - get: get50, + get: get49, } export const delete12 = oc @@ -2684,7 +2653,7 @@ export const delete12 = oc .input(z.object({ params: zDeleteWorkspacesCurrentRbacRolesByRoleIdPath })) .output(zDeleteWorkspacesCurrentRbacRolesByRoleIdResponse) -export const get51 = oc +export const get50 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2708,13 +2677,13 @@ export const put12 = oc export const byRoleId = { delete: delete12, - get: get51, + get: get50, put: put12, copy: copy2, members: members3, } -export const get52 = oc +export const get51 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2736,7 +2705,7 @@ export const post47 = oc .output(zPostWorkspacesCurrentRbacRolesResponse) export const roles = { - get: get52, + get: get51, post: post47, byRoleId, } @@ -2760,7 +2729,7 @@ export const bindings = { put: put13, } -export const get53 = oc +export const get52 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2776,10 +2745,10 @@ export const get53 = oc .output(zGetWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdMemberBindingsResponse) export const memberBindings3 = { - get: get53, + get: get52, } -export const get54 = oc +export const get53 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2795,7 +2764,7 @@ export const get54 = oc .output(zGetWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdRoleBindingsResponse) export const roleBindings3 = { - get: get54, + get: get53, } export const byPolicyId4 = { @@ -2808,7 +2777,7 @@ export const accessPolicies6 = { byPolicyId: byPolicyId4, } -export const get55 = oc +export const get54 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2819,7 +2788,7 @@ export const get55 = oc .output(zGetWorkspacesCurrentRbacWorkspaceAppsAccessPolicyResponse) export const accessPolicy3 = { - get: get55, + get: get54, } export const apps2 = { @@ -2846,7 +2815,7 @@ export const bindings2 = { put: put14, } -export const get56 = oc +export const get55 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2862,10 +2831,10 @@ export const get56 = oc .output(zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdMemberBindingsResponse) export const memberBindings4 = { - get: get56, + get: get55, } -export const get57 = oc +export const get56 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2881,7 +2850,7 @@ export const get57 = oc .output(zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdRoleBindingsResponse) export const roleBindings4 = { - get: get57, + get: get56, } export const byPolicyId5 = { @@ -2894,7 +2863,7 @@ export const accessPolicies7 = { byPolicyId: byPolicyId5, } -export const get58 = oc +export const get57 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2905,7 +2874,7 @@ export const get58 = oc .output(zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPolicyResponse) export const accessPolicy4 = { - get: get58, + get: get57, } export const datasets2 = { @@ -2930,7 +2899,7 @@ export const rbac = { workspace, } -export const get59 = oc +export const get58 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2941,7 +2910,7 @@ export const get59 = oc .output(zGetWorkspacesCurrentToolLabelsResponse) export const toolLabels = { - get: get59, + get: get58, } export const post48 = oc @@ -2974,7 +2943,7 @@ export const delete13 = { post: post49, } -export const get60 = oc +export const get59 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -2985,11 +2954,11 @@ export const get60 = oc .input(z.object({ query: zGetWorkspacesCurrentToolProviderApiGetQuery })) .output(zGetWorkspacesCurrentToolProviderApiGetResponse) -export const get61 = { - get: get60, +export const get60 = { + get: get59, } -export const get62 = oc +export const get61 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3001,7 +2970,7 @@ export const get62 = oc .output(zGetWorkspacesCurrentToolProviderApiRemoteResponse) export const remote = { - get: get62, + get: get61, } export const post50 = oc @@ -3038,7 +3007,7 @@ export const test = { pre, } -export const get63 = oc +export const get62 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3050,7 +3019,7 @@ export const get63 = oc .output(zGetWorkspacesCurrentToolProviderApiToolsResponse) export const tools = { - get: get63, + get: get62, } export const post52 = oc @@ -3071,7 +3040,7 @@ export const update2 = { export const api = { add, delete: delete13, - get: get61, + get: get60, remote, schema, test, @@ -3099,7 +3068,7 @@ export const add2 = { post: post53, } -export const get64 = oc +export const get63 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3116,10 +3085,10 @@ export const get64 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialInfoResponse) export const info = { - get: get64, + get: get63, } -export const get65 = oc +export const get64 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3139,7 +3108,7 @@ export const get65 = oc ) export const byCredentialType = { - get: get65, + get: get64, } export const schema2 = { @@ -3151,7 +3120,7 @@ export const credential = { schema: schema2, } -export const get66 = oc +export const get65 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3168,7 +3137,7 @@ export const get66 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialsResponse) export const credentials3 = { - get: get66, + get: get65, } export const post54 = oc @@ -3211,7 +3180,7 @@ export const delete14 = { post: post55, } -export const get67 = oc +export const get66 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3223,10 +3192,10 @@ export const get67 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderIconResponse) export const icon2 = { - get: get67, + get: get66, } -export const get68 = oc +export const get67 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3238,10 +3207,10 @@ export const get68 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderInfoResponse) export const info2 = { - get: get68, + get: get67, } -export const get69 = oc +export const get68 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3255,7 +3224,7 @@ export const get69 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderOauthClientSchemaResponse) export const clientSchema = { - get: get69, + get: get68, } export const delete15 = oc @@ -3273,7 +3242,7 @@ export const delete15 = oc ) .output(zDeleteWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientResponse) -export const get70 = oc +export const get69 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3304,7 +3273,7 @@ export const post56 = oc export const customClient = { delete: delete15, - get: get70, + get: get69, post: post56, } @@ -3313,7 +3282,7 @@ export const oauth = { customClient, } -export const get71 = oc +export const get70 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3325,7 +3294,7 @@ export const get71 = oc .output(zGetWorkspacesCurrentToolProviderBuiltinByProviderToolsResponse) export const tools2 = { - get: get71, + get: get70, } export const post57 = oc @@ -3380,7 +3349,7 @@ export const auth = { post: post58, } -export const get72 = oc +export const get71 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3392,14 +3361,14 @@ export const get72 = oc .output(zGetWorkspacesCurrentToolProviderMcpToolsByProviderIdResponse) export const byProviderId = { - get: get72, + get: get71, } export const tools3 = { byProviderId, } -export const get73 = oc +export const get72 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3411,7 +3380,7 @@ export const get73 = oc .output(zGetWorkspacesCurrentToolProviderMcpUpdateByProviderIdResponse) export const byProviderId2 = { - get: get73, + get: get72, } export const update4 = { @@ -3490,7 +3459,7 @@ export const delete17 = { post: post61, } -export const get74 = oc +export const get73 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3501,11 +3470,11 @@ export const get74 = oc .input(z.object({ query: zGetWorkspacesCurrentToolProviderWorkflowGetQuery.optional() })) .output(zGetWorkspacesCurrentToolProviderWorkflowGetResponse) -export const get75 = { - get: get74, +export const get74 = { + get: get73, } -export const get76 = oc +export const get75 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3517,7 +3486,7 @@ export const get76 = oc .output(zGetWorkspacesCurrentToolProviderWorkflowToolsResponse) export const tools4 = { - get: get76, + get: get75, } export const post62 = oc @@ -3538,7 +3507,7 @@ export const update5 = { export const workflow = { create: create2, delete: delete17, - get: get75, + get: get74, tools: tools4, update: update5, } @@ -3550,7 +3519,7 @@ export const toolProvider = { workflow, } -export const get77 = oc +export const get76 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3562,10 +3531,10 @@ export const get77 = oc .output(zGetWorkspacesCurrentToolProvidersResponse) export const toolProviders = { - get: get77, + get: get76, } -export const get78 = oc +export const get77 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3576,10 +3545,10 @@ export const get78 = oc .output(zGetWorkspacesCurrentToolsApiResponse) export const api2 = { - get: get78, + get: get77, } -export const get79 = oc +export const get78 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3590,10 +3559,10 @@ export const get79 = oc .output(zGetWorkspacesCurrentToolsBuiltinResponse) export const builtin2 = { - get: get79, + get: get78, } -export const get80 = oc +export const get79 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3604,10 +3573,10 @@ export const get80 = oc .output(zGetWorkspacesCurrentToolsMcpResponse) export const mcp2 = { - get: get80, + get: get79, } -export const get81 = oc +export const get80 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3618,7 +3587,7 @@ export const get81 = oc .output(zGetWorkspacesCurrentToolsWorkflowResponse) export const workflow2 = { - get: get81, + get: get80, } export const tools5 = { @@ -3628,7 +3597,7 @@ export const tools5 = { workflow: workflow2, } -export const get82 = oc +export const get81 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3640,13 +3609,13 @@ export const get82 = oc .output(zGetWorkspacesCurrentTriggerProviderByProviderIconResponse) export const icon3 = { - get: get82, + get: get81, } /** * Get info for a trigger provider */ -export const get83 = oc +export const get82 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3659,7 +3628,7 @@ export const get83 = oc .output(zGetWorkspacesCurrentTriggerProviderByProviderInfoResponse) export const info3 = { - get: get83, + get: get82, } /** @@ -3680,7 +3649,7 @@ export const delete18 = oc /** * Get OAuth client configuration for a provider */ -export const get84 = oc +export const get83 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3714,7 +3683,7 @@ export const post63 = oc export const client = { delete: delete18, - get: get84, + get: get83, post: post63, } @@ -3781,7 +3750,7 @@ export const create3 = { /** * Get the request logs for a subscription instance for a trigger provider */ -export const get85 = oc +export const get84 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3802,7 +3771,7 @@ export const get85 = oc ) export const bySubscriptionBuilderId2 = { - get: get85, + get: get84, } export const logs = { @@ -3876,7 +3845,7 @@ export const verifyAndUpdate = { /** * Get a subscription instance for a trigger provider */ -export const get86 = oc +export const get85 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3897,7 +3866,7 @@ export const get86 = oc ) export const bySubscriptionBuilderId5 = { - get: get86, + get: get85, } export const builder = { @@ -3912,7 +3881,7 @@ export const builder = { /** * List all trigger subscriptions for the current tenant's provider */ -export const get87 = oc +export const get86 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3925,13 +3894,13 @@ export const get87 = oc .output(zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsListResponse) export const list4 = { - get: get87, + get: get86, } /** * Initiate OAuth authorization flow for a trigger provider */ -export const get88 = oc +export const get87 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -3948,7 +3917,7 @@ export const get88 = oc .output(zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsOauthAuthorizeResponse) export const authorize = { - get: get88, + get: get87, } export const oauth3 = { @@ -4065,7 +4034,7 @@ export const triggerProvider = { /** * List all trigger providers for the current tenant */ -export const get89 = oc +export const get88 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -4077,7 +4046,7 @@ export const get89 = oc .output(zGetWorkspacesCurrentTriggersResponse) export const triggers = { - get: get89, + get: get88, } export const post71 = oc @@ -4177,7 +4146,7 @@ export const switch3 = { post: post75, } -export const get90 = oc +export const get89 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -4189,7 +4158,7 @@ export const get90 = oc .output(zGetWorkspacesByTenantIdModelProvidersByProviderByIconTypeByLangResponse) export const byLang = { - get: get90, + get: get89, } export const byIconType = { @@ -4208,7 +4177,7 @@ export const byTenantId = { modelProviders: modelProviders2, } -export const get91 = oc +export const get90 = oc .route({ inputStructure: 'detailed', method: 'GET', @@ -4219,7 +4188,7 @@ export const get91 = oc .output(zGetWorkspacesResponse) export const workspaces = { - get: get91, + get: get90, current, customConfig, info: info4, diff --git a/packages/contracts/generated/api/console/workspaces/types.gen.ts b/packages/contracts/generated/api/console/workspaces/types.gen.ts index 29f23567e95..913db9fbebe 100644 --- a/packages/contracts/generated/api/console/workspaces/types.gen.ts +++ b/packages/contracts/generated/api/console/workspaces/types.gen.ts @@ -31,12 +31,12 @@ export type AgentProviderListResponse = Array<{ [key: string]: unknown }> -export type SnippetPagination = { - data?: Array - has_more?: boolean - limit?: number - page?: number - total?: number +export type SnippetPaginationResponse = { + data: Array + has_more: boolean + limit: number + page: number + total: number } export type CreateSnippetPayload = { @@ -50,28 +50,28 @@ export type CreateSnippetPayload = { type?: 'group' | 'node' } -export type Snippet = { - created_at?: number - created_by?: AnonymousInlineModelB0Fd3F86D9D5 - description?: string +export type SnippetResponse = { + created_at?: number | null + created_by?: SimpleAccountResponse | null + description?: string | null graph?: { [key: string]: unknown - } + } | null icon_info?: { [key: string]: unknown - } - id?: string - input_fields?: { + } | null + id: string + input_fields?: Array<{ [key: string]: unknown - } - is_published?: boolean - name?: string - tags?: Array - type?: string - updated_at?: number - updated_by?: AnonymousInlineModelB0Fd3F86D9D5 - use_count?: number - version?: number + }> | null + is_published: boolean + name: string + tags?: Array + type: string + updated_at?: number | null + updated_by?: SimpleAccountResponse | null + use_count: number + version: number } export type SnippetImportPayload = { @@ -83,8 +83,13 @@ export type SnippetImportPayload = { yaml_url?: string | null } -export type SnippetImportResponse = { - [key: string]: unknown +export type SnippetImportInfo = { + current_dsl_version?: string + error?: string + id: string + imported_dsl_version?: string + snippet_id?: string | null + status: ImportStatus } export type UpdateSnippetPayload = { @@ -93,19 +98,17 @@ export type UpdateSnippetPayload = { name?: string | null } -export type SnippetDependencyCheckResponse = { - [key: string]: unknown +export type CheckDependenciesResult = { + leaked_dependencies?: Array } -export type TextFileResponse = string - -export type SnippetUseCountResponse = { +export type SnippetUseCountIncrementResponse = { result: string use_count: number } -export type AccountWithRoleList = { - accounts: Array +export type AccountWithRoleListResponse = { + accounts: Array } export type DefaultModelDataResponse = { @@ -872,23 +875,23 @@ export type WorkspaceCustomConfigResponse = { replace_webapp_logo?: string | null } -export type AnonymousInlineModel744Ff9Cc03E6 = { - author_name?: string - created_at?: number - created_by?: string - description?: string +export type SnippetListItemResponse = { + author_name?: string | null + created_at?: number | null + created_by?: string | null + description?: string | null icon_info?: { [key: string]: unknown - } - id?: string - is_published?: boolean - name?: string - tags?: Array - type?: string - updated_at?: number - updated_by?: string - use_count?: number - version?: number + } | null + id: string + is_published: boolean + name: string + tags?: Array + type: string + updated_at?: number | null + updated_by?: string | null + use_count: number + version: number } export type IconInfo = { @@ -909,19 +912,27 @@ export type InputFieldDefinition = { type?: string | null } -export type AnonymousInlineModelB0Fd3F86D9D5 = { - email?: string - id?: string - name?: string +export type SimpleAccountResponse = { + email: string + id: string + name: string } -export type AnonymousInlineModel7B8B49Ca164e = { - id?: string - name?: string - type?: string +export type SnippetTagResponse = { + id: string + name: string + type: string } -export type AccountWithRole = { +export type ImportStatus = 'completed' | 'completed-with-warnings' | 'failed' | 'pending' + +export type PluginDependency = { + current_identifier?: string | null + type: Type + value: Github | Marketplace | Package +} + +export type AccountWithRoleResponse = { avatar?: string | null created_at?: number | null email: string @@ -1198,6 +1209,25 @@ export type WorkflowToolParameterConfiguration = { name: string } +export type Type = 'github' | 'marketplace' | 'package' + +export type Github = { + github_plugin_unique_identifier: string + package: string + repo: string + version: string +} + +export type Marketplace = { + marketplace_plugin_unique_identifier: string + version?: string | null +} + +export type Package = { + plugin_unique_identifier: string + version?: string | null +} + export type SimpleProviderEntityResponse = { icon_small?: I18nObject | null icon_small_dark?: I18nObject | null @@ -1583,7 +1613,7 @@ export type GetWorkspacesCurrentCustomizedSnippetsData = { } export type GetWorkspacesCurrentCustomizedSnippetsResponses = { - 200: SnippetPagination + 200: SnippetPaginationResponse } export type GetWorkspacesCurrentCustomizedSnippetsResponse @@ -1601,7 +1631,7 @@ export type PostWorkspacesCurrentCustomizedSnippetsErrors = { } export type PostWorkspacesCurrentCustomizedSnippetsResponses = { - 201: Snippet + 201: SnippetResponse } export type PostWorkspacesCurrentCustomizedSnippetsResponse @@ -1619,8 +1649,8 @@ export type PostWorkspacesCurrentCustomizedSnippetsImportsErrors = { } export type PostWorkspacesCurrentCustomizedSnippetsImportsResponses = { - 200: SnippetImportResponse - 202: SnippetImportResponse + 200: SnippetImportInfo + 202: SnippetImportInfo } export type PostWorkspacesCurrentCustomizedSnippetsImportsResponse @@ -1640,7 +1670,7 @@ export type PostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmError } export type PostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmResponses = { - 200: SnippetImportResponse + 200: SnippetImportInfo } export type PostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmResponse @@ -1680,7 +1710,7 @@ export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdErrors = { } export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponses = { - 200: Snippet + 200: SnippetResponse } export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse @@ -1701,7 +1731,7 @@ export type PatchWorkspacesCurrentCustomizedSnippetsBySnippetIdErrors = { } export type PatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponses = { - 200: Snippet + 200: SnippetResponse } export type PatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse @@ -1721,34 +1751,12 @@ export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesEr } export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponses = { - 200: SnippetDependencyCheckResponse + 200: CheckDependenciesResult } export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponse = GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponses[keyof GetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponses] -export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportData = { - body?: never - path: { - snippet_id: string - } - query?: { - include_secret?: string - } - url: '/workspaces/current/customized-snippets/{snippet_id}/export' -} - -export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportErrors = { - 404: unknown -} - -export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponses = { - 200: TextFileResponse -} - -export type GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse - = GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponses[keyof GetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponses] - export type PostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementData = { body?: never path: { @@ -1763,7 +1771,7 @@ export type PostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementE } export type PostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementResponses = { - 200: SnippetUseCountResponse + 200: SnippetUseCountIncrementResponse } export type PostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementResponse @@ -1777,7 +1785,7 @@ export type GetWorkspacesCurrentDatasetOperatorsData = { } export type GetWorkspacesCurrentDatasetOperatorsResponses = { - 200: AccountWithRoleList + 200: AccountWithRoleListResponse } export type GetWorkspacesCurrentDatasetOperatorsResponse @@ -2004,7 +2012,7 @@ export type GetWorkspacesCurrentMembersData = { } export type GetWorkspacesCurrentMembersResponses = { - 200: AccountWithRoleList + 200: AccountWithRoleListResponse } export type GetWorkspacesCurrentMembersResponse diff --git a/packages/contracts/generated/api/console/workspaces/zod.gen.ts b/packages/contracts/generated/api/console/workspaces/zod.gen.ts index fb6f643d7a9..168788d808a 100644 --- a/packages/contracts/generated/api/console/workspaces/zod.gen.ts +++ b/packages/contracts/generated/api/console/workspaces/zod.gen.ts @@ -27,24 +27,9 @@ export const zSnippetImportPayload = z.object({ }) /** - * SnippetImportResponse + * SnippetUseCountIncrementResponse */ -export const zSnippetImportResponse = z.record(z.string(), z.unknown()) - -/** - * SnippetDependencyCheckResponse - */ -export const zSnippetDependencyCheckResponse = z.record(z.string(), z.unknown()) - -/** - * TextFileResponse - */ -export const zTextFileResponse = z.string() - -/** - * SnippetUseCountResponse - */ -export const zSnippetUseCountResponse = z.object({ +export const zSnippetUseCountIncrementResponse = z.object({ result: z.string(), use_count: z.int(), }) @@ -801,97 +786,97 @@ export const zCreateSnippetPayload = z.object({ type: z.enum(['group', 'node']).optional().default('node'), }) -export const zAnonymousInlineModelB0Fd3F86D9D5 = z.object({ - email: z.string().optional(), - id: z.string().optional(), - name: z.string().optional(), -}) - -export const zAnonymousInlineModel7B8B49Ca164e = z.object({ - id: z.string().optional(), - name: z.string().optional(), - type: z.string().optional(), -}) - -export const zSnippet = z.object({ - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: zAnonymousInlineModelB0Fd3F86D9D5.optional(), - description: z.string().optional(), - graph: z.record(z.string(), z.unknown()).optional(), - icon_info: z.record(z.string(), z.unknown()).optional(), - id: z.string().optional(), - input_fields: z.record(z.string(), z.unknown()).optional(), - is_published: z.boolean().optional(), - name: z.string().optional(), - tags: z.array(zAnonymousInlineModel7B8B49Ca164e).optional(), - type: z.string().optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: zAnonymousInlineModelB0Fd3F86D9D5.optional(), - use_count: z.int().optional(), - version: z.int().optional(), -}) - -export const zAnonymousInlineModel744Ff9Cc03E6 = z.object({ - author_name: z.string().optional(), - created_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - created_by: z.string().optional(), - description: z.string().optional(), - icon_info: z.record(z.string(), z.unknown()).optional(), - id: z.string().optional(), - is_published: z.boolean().optional(), - name: z.string().optional(), - tags: z.array(zAnonymousInlineModel7B8B49Ca164e).optional(), - type: z.string().optional(), - updated_at: z.coerce - .bigint() - .min(BigInt('-9223372036854775808'), { - error: 'Invalid value: Expected int64 to be >= -9223372036854775808', - }) - .max(BigInt('9223372036854775807'), { - error: 'Invalid value: Expected int64 to be <= 9223372036854775807', - }) - .optional(), - updated_by: z.string().optional(), - use_count: z.int().optional(), - version: z.int().optional(), -}) - -export const zSnippetPagination = z.object({ - data: z.array(zAnonymousInlineModel744Ff9Cc03E6).optional(), - has_more: z.boolean().optional(), - limit: z.int().optional(), - page: z.int().optional(), - total: z.int().optional(), +/** + * SimpleAccountResponse + */ +export const zSimpleAccountResponse = z.object({ + email: z.string(), + id: z.string(), + name: z.string(), }) /** - * AccountWithRole + * SnippetTagResponse */ -export const zAccountWithRole = z.object({ +export const zSnippetTagResponse = z.object({ + id: z.string(), + name: z.string(), + type: z.string(), +}) + +/** + * SnippetResponse + */ +export const zSnippetResponse = z.object({ + created_at: z.int().nullish(), + created_by: zSimpleAccountResponse.nullish(), + description: z.string().nullish(), + graph: z.record(z.string(), z.unknown()).nullish(), + icon_info: z.record(z.string(), z.unknown()).nullish(), + id: z.string(), + input_fields: z.array(z.record(z.string(), z.unknown())).nullish(), + is_published: z.boolean(), + name: z.string(), + tags: z.array(zSnippetTagResponse).optional(), + type: z.string(), + updated_at: z.int().nullish(), + updated_by: zSimpleAccountResponse.nullish(), + use_count: z.int(), + version: z.int(), +}) + +/** + * SnippetListItemResponse + */ +export const zSnippetListItemResponse = z.object({ + author_name: z.string().nullish(), + created_at: z.int().nullish(), + created_by: z.string().nullish(), + description: z.string().nullish(), + icon_info: z.record(z.string(), z.unknown()).nullish(), + id: z.string(), + is_published: z.boolean(), + name: z.string(), + tags: z.array(zSnippetTagResponse).optional(), + type: z.string(), + updated_at: z.int().nullish(), + updated_by: z.string().nullish(), + use_count: z.int(), + version: z.int(), +}) + +/** + * SnippetPaginationResponse + */ +export const zSnippetPaginationResponse = z.object({ + data: z.array(zSnippetListItemResponse), + has_more: z.boolean(), + limit: z.int(), + page: z.int(), + total: z.int(), +}) + +/** + * ImportStatus + */ +export const zImportStatus = z.enum(['completed', 'completed-with-warnings', 'failed', 'pending']) + +/** + * SnippetImportInfo + */ +export const zSnippetImportInfo = z.object({ + current_dsl_version: z.string().optional().default('0.1.0'), + error: z.string().optional().default(''), + id: z.string(), + imported_dsl_version: z.string().optional().default(''), + snippet_id: z.string().nullish(), + status: zImportStatus, +}) + +/** + * AccountWithRoleResponse + */ +export const zAccountWithRoleResponse = z.object({ avatar: z.string().nullish(), created_at: z.int().nullish(), email: z.string(), @@ -905,10 +890,10 @@ export const zAccountWithRole = z.object({ }) /** - * AccountWithRoleList + * AccountWithRoleListResponse */ -export const zAccountWithRoleList = z.object({ - accounts: z.array(zAccountWithRole), +export const zAccountWithRoleListResponse = z.object({ + accounts: z.array(zAccountWithRoleResponse), }) /** @@ -1374,6 +1359,53 @@ export const zMcpProviderUpdatePayload = z.object({ server_url: z.string(), }) +/** + * Type + */ +export const zType = z.enum(['github', 'marketplace', 'package']) + +/** + * Github + */ +export const zGithub = z.object({ + github_plugin_unique_identifier: z.string(), + package: z.string(), + repo: z.string(), + version: z.string(), +}) + +/** + * Marketplace + */ +export const zMarketplace = z.object({ + marketplace_plugin_unique_identifier: z.string(), + version: z.string().nullish(), +}) + +/** + * Package + */ +export const zPackage = z.object({ + plugin_unique_identifier: z.string(), + version: z.string().nullish(), +}) + +/** + * PluginDependency + */ +export const zPluginDependency = z.object({ + current_identifier: z.string().nullish(), + type: zType, + value: z.union([zGithub, zMarketplace, zPackage]), +}) + +/** + * CheckDependenciesResult + */ +export const zCheckDependenciesResult = z.object({ + leaked_dependencies: z.array(zPluginDependency).optional(), +}) + /** * ConfigurateMethod * @@ -2183,21 +2215,21 @@ export const zGetWorkspacesCurrentCustomizedSnippetsQuery = z.object({ /** * Snippets retrieved successfully */ -export const zGetWorkspacesCurrentCustomizedSnippetsResponse = zSnippetPagination +export const zGetWorkspacesCurrentCustomizedSnippetsResponse = zSnippetPaginationResponse export const zPostWorkspacesCurrentCustomizedSnippetsBody = zCreateSnippetPayload /** * Snippet created successfully */ -export const zPostWorkspacesCurrentCustomizedSnippetsResponse = zSnippet +export const zPostWorkspacesCurrentCustomizedSnippetsResponse = zSnippetResponse export const zPostWorkspacesCurrentCustomizedSnippetsImportsBody = zSnippetImportPayload /** * Snippet imported successfully */ -export const zPostWorkspacesCurrentCustomizedSnippetsImportsResponse = zSnippetImportResponse +export const zPostWorkspacesCurrentCustomizedSnippetsImportsResponse = zSnippetImportInfo export const zPostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmPath = z.object({ import_id: z.string(), @@ -2207,7 +2239,7 @@ export const zPostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmPat * Import confirmed successfully */ export const zPostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmResponse - = zSnippetImportResponse + = zSnippetImportInfo export const zDeleteWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object({ snippet_id: z.uuid(), @@ -2225,7 +2257,7 @@ export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object({ /** * Snippet retrieved successfully */ -export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippet +export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippetResponse export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdBody = zUpdateSnippetPayload @@ -2236,7 +2268,7 @@ export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object /** * Snippet updated successfully */ -export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippet +export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippetResponse export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesPath = z.object({ snippet_id: z.uuid(), @@ -2246,20 +2278,7 @@ export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependencies * Dependencies checked successfully */ export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponse - = zSnippetDependencyCheckResponse - -export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportPath = z.object({ - snippet_id: z.uuid(), -}) - -export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportQuery = z.object({ - include_secret: z.string().optional().default('false'), -}) - -/** - * Snippet exported successfully - */ -export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse = zTextFileResponse + = zCheckDependenciesResult export const zPostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementPath = z.object({ snippet_id: z.uuid(), @@ -2269,12 +2288,12 @@ export const zPostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncremen * Use count incremented successfully */ export const zPostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementResponse - = zSnippetUseCountResponse + = zSnippetUseCountIncrementResponse /** * Success */ -export const zGetWorkspacesCurrentDatasetOperatorsResponse = zAccountWithRoleList +export const zGetWorkspacesCurrentDatasetOperatorsResponse = zAccountWithRoleListResponse export const zGetWorkspacesCurrentDefaultModelQuery = z.object({ model_type: z.enum(['llm', 'moderation', 'rerank', 'speech2text', 'text-embedding', 'tts']), @@ -2378,7 +2397,7 @@ export const zPatchWorkspacesCurrentEndpointsByIdResponse = zEndpointUpdateRespo /** * Success */ -export const zGetWorkspacesCurrentMembersResponse = zAccountWithRoleList +export const zGetWorkspacesCurrentMembersResponse = zAccountWithRoleListResponse export const zPostWorkspacesCurrentMembersInviteEmailBody = zMemberInvitePayload diff --git a/packages/contracts/generated/api/service/types.gen.ts b/packages/contracts/generated/api/service/types.gen.ts index 97921643514..ebce941aecf 100644 --- a/packages/contracts/generated/api/service/types.gen.ts +++ b/packages/contracts/generated/api/service/types.gen.ts @@ -1414,7 +1414,7 @@ export type SelectInputConfig = { type?: 'select' } -export type SimpleAccount = { +export type SimpleAccountResponse = { email: string id: string name: string @@ -1572,7 +1572,7 @@ export type WorkflowAppLogPaginationResponse = { export type WorkflowAppLogPartialResponse = { created_at?: number | null - created_by_account?: SimpleAccount | null + created_by_account?: SimpleAccountResponse | null created_by_end_user?: SimpleEndUser | null created_by_role?: string | null created_from?: string | null diff --git a/packages/contracts/generated/api/service/zod.gen.ts b/packages/contracts/generated/api/service/zod.gen.ts index 6ccc5671cb2..1d6c5cec40f 100644 --- a/packages/contracts/generated/api/service/zod.gen.ts +++ b/packages/contracts/generated/api/service/zod.gen.ts @@ -1676,9 +1676,9 @@ export const zProcessRule = z.object({ }) /** - * SimpleAccount + * SimpleAccountResponse */ -export const zSimpleAccount = z.object({ +export const zSimpleAccountResponse = z.object({ email: z.string(), id: z.string(), name: z.string(), @@ -2196,7 +2196,7 @@ export const zWorkflowRunForLogResponse = z.object({ */ export const zWorkflowAppLogPartialResponse = z.object({ created_at: z.int().nullish(), - created_by_account: zSimpleAccount.nullish(), + created_by_account: zSimpleAccountResponse.nullish(), created_by_end_user: zSimpleEndUser.nullish(), created_by_role: z.string().nullish(), created_from: z.string().nullish(), diff --git a/packages/contracts/openapi-ts.api.config.ts b/packages/contracts/openapi-ts.api.config.ts index 8fce8a25bd3..1adbf4fda8e 100644 --- a/packages/contracts/openapi-ts.api.config.ts +++ b/packages/contracts/openapi-ts.api.config.ts @@ -10,13 +10,21 @@ type SwaggerSchema = JsonObject & { $ref?: string } +type OpenApiMediaType = JsonObject & { + schema?: SwaggerSchema +} + +type OpenApiResponse = JsonObject & { + content?: Record +} + type OpenApiComponents = JsonObject & { schemas?: Record } type SwaggerOperation = JsonObject & { operationId?: string - responses?: Record + responses?: Record } type SwaggerDocument = JsonObject & { @@ -52,6 +60,17 @@ const currentDir = path.dirname(fileURLToPath(import.meta.url)) const apiOpenApiDir = path.resolve(currentDir, 'openapi') const operationMethods = new Set(['delete', 'get', 'patch', 'post', 'put']) +const pydanticDecimalStringPattern = '^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$' +const codegenSafeDecimalStringPattern = '^(?![-+.]*$)[+-]?0*\\d*\\.?\\d*$' + +const opaqueJsonContent = (): Record => ({ + 'application/json': { + schema: { + additionalProperties: true, + type: 'object', + }, + }, +}) const apiSpecs: ApiSpec[] = [ { filename: 'console-openapi.json', name: 'console' }, @@ -182,6 +201,46 @@ const addOperationIds = (document: SwaggerDocument) => { } } +const isOpaqueContractResponse = (response: OpenApiResponse) => { + const content = response.content + if (!isObject(content)) + return false + + return Object.entries(content).some(([mediaType, media]) => { + if (!isObject(media)) + return false + + return (mediaType === 'application/json' || mediaType === 'text/event-stream') && !('schema' in media) + }) +} + +const hasOpaqueContractSuccessResponse = (operation: SwaggerOperation) => { + return Object.entries(operation.responses ?? {}).some(([status, response]) => { + return /^2\d\d$/.test(status) && isObject(response) && isOpaqueContractResponse(response) + }) +} + +const normalizeOpaqueContractResponses = (document: SwaggerDocument) => { + // Some backend endpoints has no schema (e.g. external) and will trap heyapi here + // So we forge an opaque schema here + for (const pathItem of Object.values(document.paths ?? {})) { + for (const [method, operation] of Object.entries(pathItem)) { + if (!operationMethods.has(method) || !isObject(operation)) + continue + + const swaggerOperation = operation as SwaggerOperation + if (!hasOpaqueContractSuccessResponse(swaggerOperation)) + continue + + Object.values(swaggerOperation.responses ?? {}) + .filter(response => isObject(response) && isOpaqueContractResponse(response)) + .forEach((response) => { + response.content = opaqueJsonContent() + }) + } + } +} + const hasSuccessResponse = (operation: SwaggerOperation) => { return Object.entries(operation.responses ?? {}).some(([status, response]) => { if (!/^2\d\d$/.test(status)) @@ -215,6 +274,7 @@ const filterContractOperations = (document: SwaggerDocument) => { } const normalizeApiSwagger = (document: SwaggerDocument) => { + normalizeOpaqueContractResponses(document) filterContractOperations(document) addOperationIds(document) @@ -380,10 +440,20 @@ const createApiConfig = (job: ApiJob): UserConfig => ({ 'name': 'zod', '~resolvers': { string: (ctx) => { - if (ctx.schema.format !== 'binary') - return undefined + if (ctx.schema.format === 'binary') + return $(ctx.symbols.z).attr('custom').call().generic($.type.or($.type('Blob'), $.type('File'))) - return $(ctx.symbols.z).attr('custom').call().generic($.type.or($.type('Blob'), $.type('File'))) + if (ctx.schema.pattern === pydanticDecimalStringPattern) { + // the pydantic generated regex will emit error like + // regexp/no-useless-assertions, so patch the regex here + return $(ctx.symbols.z) + .attr('string') + .call() + .attr('regex') + .call($.regexp(codegenSafeDecimalStringPattern)) + } + + return undefined }, }, },