Rechercher

Pergunta
· Abr. 7

How to convert persistent object to dynamic object

Hi devs!

Suppose I have an instance of a persistent class:

Set person = ##class(dc.Sample.Person).%OpenId(1)

Class is an ancestor of %JSON.Adapter.

How can I convert it to dynamic object with the properties that person.%JSONExport() provides?

{"Name":"Elon Mask","Title":"Associate Accountant","Company":"InterSystems","Phone":"799-933-5569","DOB":"1926-12-11"}

Couldn't find a right method. 

set dynObj = ##class(%ZEN.Auxiliary.altJSONProvider).%ObjectToAET(person) works, but adds id and classname, which I don't want to be added:

zw dynObj
dynObj={"_class":"dc.Sample.Person","_id":1,"Name":"Elon Mask","Title":"Associate Accountant","Company":"InterSystems","Phone":"799-933-5569","DOB":31390}  ;

Thoughts?

17 Comments
Discussão (17)5
Entre ou crie uma conta para continuar
Artigo
· Abr. 7 2min de leitura

¡Hey, chat! ¿Qué pasa con mi interoperabilidad?

¿Qué pasaría si pudierais hablar en un chat para comprobar qué sucede en Interoperabilidad, ver si hay errores e incluso resolver algunos tipos de problemas?

Con el servidor MCP, podéis conectar cualquiera de vuestros clientes MCP, por ejemplo, Claude, a IRIS y pedirle que revise la Interoperabilidad.

Lo que necesitáis es una configuración sencilla de Claude.

En la sección de Desarrollador de los ajustes de Claude, podéis encontrar un archivo de configuración.

Con una configuración sencilla, como esta, solo se requiere acceso a IRIS; no es necesario instalar nada en IRIS.

{
  "mcpServers": {
    "iris": {
      "command": "uvx",
      "args": [
        "mcp-server-iris"
      ],
      "env": {
        "IRIS_HOSTNAME": "localhost",
        "IRIS_PORT": "1972",
        "IRIS_NAMESPACE": "USER",
        "IRIS_USERNAME": "_SYSTEM",
        "IRIS_PASSWORD": "SYS"
      }
    }
  }
}

Después de reiniciar Claude, debería mostrar que algunas herramientas MCP están disponibles. Al hacer clic allí, se mostrarán todas las herramientas disponibles.

Claude, al conocer las herramientas disponibles y según el mensaje que proporcionéis, puede seleccionar la herramienta que mejor se adapte para ayudar con la consulta.

Supongamos que funciona bien, vamos a comprobar si hay errores.

Podemos ver la respuesta actual de la herramienta. Claude analiza la salida y extrae los errores que encuentra, sugiriendo por qué pueden ocurrir y ofreciendo formas de solucionarlos.

Actualmente, la implementación de este servidor MCP no ofrece capacidades para editar el código, por lo que no vamos a pedir que se corrija el código. Pero podemos intentar recuperar la producción.

Reiniciarlo suele ayudar

Aquí estamos, todo bien ahora.

Bueno, ya que nuestra producción está funcionando correctamente, echemos un vistazo a los datos que ya hemos recolectado.

Para ayudar con esto, Claude usará una herramienta que puede ejecutar consultas SQL.

Aunque puse el nombre de la clase en lugar del nombre de la tabla, y descubrió que no existía dicha tabla, no se rindió. En una sola sesión, logró averiguar el nombre real de la tabla y obtener algunos datos.

Cuando intentó obtener más información sobre los datos recolectados, incluso trató de adivinar los nombres de las columnas.

Encontró las columnas reales, pero tuvo dificultades con las palabras reservadas y no intentó usar "FOUND".

Y con un último intento...

Decidió mantenerlo simple, pero usando el conocimiento sobre los nombres de las columnas, lo acertó y proporcionó un resumen.

En esta etapa, el MCP parece estar en el principio de su viaje, pero aún así tenemos una herramienta bastante buena.

Si os gusta esta herramienta, por favor, votad en el actual Concurso de OpenExchange Contest 

Discussão (0)1
Entre ou crie uma conta para continuar
Discussão (4)3
Entre ou crie uma conta para continuar
Anúncio
· Abr. 7

Resultados de los Bonus Tecnológicos para el Concurso de Programación de IA de InterSystems en inglés

¡Hola desarrolladores!

¡Estamos felices de presentar la página de bonificaciones para las aplicaciones enviadas al Concurso de Programación de IA de InterSystems!

Ved los resultados a continuación.

Proyecto

Agent AI

Vector Search

Embedded Python

LLM AI or LangChain

IntegratedML

Docker

IPM

Online Demo

Community Idea Implementation

Find a bug

First Article on DC

Second Article on DC

Video on YouTube

First Time Contribution

Suggest New Idea

Total Bonus

Nominal 5 4 3 3 3 2 2 2 4 2 2 1 3 3 1 40
ollama-ai-iris   4 3 3             2     3   15
mcp-server-iris 5   3 3             2   3     16
langchain-iris-tool 5 4 3 3   2 2 2 4   2 1 3   1 32
AiAssistant   4 3 3   2 2             3   17
pax-ai-iris     3                     3   6
IRIS-Intelligent-Butler   4 3 3                   3   13
iris-data-analysis   4 3 3   2 2       2     3   19
bg-iris-agent 5     3   2 2 2     2   3 3   22
Facilis 5   3 3   2         2         15
Vitals Lab   4   3                 3 3   13
iris-AgenticAI 5 4 3 3   2         2 1       20
toot   4 3     2         2     3   14
iris-clinical-assistant     3 3   2               3   11
oncorag 5 4   3   2               3   17
iris-easybot 5 4 3     2                   14

Por favor, aplicad vuestros comentarios para nuevas implementaciones y correcciones que deban realizarse aquí en los comentarios o en Discord.

Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· Abr. 7

OAuth2: Retrieve access_token and prevent login if it's valid

We have an OAuth server configured as an identity provider, and we have an external application (from another provider) that connects correctly with OAuth.

Due to the needs of the project, what we want to do is the following:

  • If the user is not authenticated, show the OAuth login page, have them log in, and redirect them to the third-party app --> This part works
  • If the user is already authenticated (already logged in and already has a valid access_token), we create a cookie with the access_token generated at login, and when entering the third-party application URL, instead of showing the OAuth login, if the access_token is valid, redirect directly to the third-party application --> This is the part we can't get working

What do we have?

  • We have created a custom class "test.oauth.server.Authenticate" that extends from %OAuth2.Server.Authenticate.
  • We've added the BeforeAuthenticate method. Here we're able to read the request cookies, find the one we created, get the access_token, validate it, and then get the token itself:
Include Ensemble

Class test.oauth.server.Authenticate Extends %OAuth2.Server.Authenticate
{

ClassMethod BeforeAuthenticate(scope As %ArrayOfDataTypes, properties As %OAuth2.Server.Properties) As %Status
{
    $$$LOGINFO("Entrando en BeforeAuthenticate")

	set currentNS = $Namespace
    Set httpRequest = %request
    Set tokenCookie = httpRequest.GetCookie("SessionToken")

    If tokenCookie '= "" {
        $$$LOGINFO("Token encontrado en Cookie: "_tokenCookie)
        
        // Llamar manualmente a GetAccessToken con el token de la cookie
        If ..GetAccessToken(tokenCookie) {
            Set isValid = ##class(%SYS.OAuth2.Validation).ValidateJWT("ValidarToken", tokenCookie, , , .jsonObject, .securityParameters, .sc)
            $$$LOGINFO(isValid_" ("_sc_"): "_$System.Status.GetErrorText(sc))
            $$$LOGINFO(jsonObject.%ToJSON())
            
            set $Namespace = "%SYS"
            Set token=##class(OAuth2.Server.AccessToken).OpenByToken(tokenCookie,.sc)
            set $Namespace = currentNS
            
            $$$LOGINFO(token_" ("_sc_"): "_$System.Status.GetErrorText(sc))
            
            Quit 1 // Continuar sin mostrar login
        } Else {
            $$$LOGINFO("GetAccessToken rechazó el token")
            Quit $$$OK
        }
    }

    $$$LOGINFO("No se encontró token en Cookie")
    Quit $$$OK
}

ClassMethod GetAccessToken(ByRef AccessToken As %String) As %Boolean
{
    $$$LOGINFO("Entrando en GetAccessToken")
    
    // Si ya recibimos un token desde BeforeAuthenticate
    If AccessToken '= "" {
        // Token recibido en GetAccessToken
        // Llamar a la función de validación de token
        Set sc = ##class(%SYS.OAuth2.Validation).ValidateJWT("ValidarToken", AccessToken, , , .jsonObject, .securityParameters)
        Set user = jsonObject.sub
        $$$LOGINFO("Token válido. Usuario: "_user)
        If user '= "" {
            $$$LOGINFO("Usuario autenticado: "_user)
            Quit $$$OK
        } Else {
            $$$LOGINFO("El usuario está vacío.")
            Quit 0  // Retorna 0 si el usuario es vacío
        }
    }
    
    Quit 0  // Asegúrate de retornar 0 si no se obtiene el token
}

}

But no matter what, even if we have the access_token, open the OAuth Token object, etc., it still shows the login. We think we're missing something, but we don't know what...

What can we do? Any ideas?

Thank you!

1 Comment
Discussão (1)0
Entre ou crie uma conta para continuar