Giter Club home page Giter Club logo

api-clients's Introduction

api-clients's People

Contributors

dependabot[bot] avatar horeaporutiu avatar janza avatar kirillsud avatar lucasrollan avatar mahito avatar marcospinello avatar mettin avatar ruslan-kotowski avatar simpikkle avatar sindunuragarp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

api-clients's Issues

Failed pydantic validation of miro data for connectors (seems like one of ConnectorStyle type missing in python enum)

When querying for connection in board 'uXjVK8dMhnw='

  File "/Users/kdanylov/venvs/speechy/lib/python3.11/site-packages/miro_api/api_client.py", line 394, in __deserialize
    return self.__deserialize_model(data, klass)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kdanylov/venvs/speechy/lib/python3.11/site-packages/miro_api/api_client.py", line 659, in __deserialize_model
    return klass.from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kdanylov/venvs/speechy/lib/python3.11/site-packages/miro_api/models/connectors_cursor_paged.py", line 123, in from_dict
    [ConnectorWithLinks.from_dict(_item) for _item in obj["data"]]
  File "/Users/kdanylov/venvs/speechy/lib/python3.11/site-packages/miro_api/models/connectors_cursor_paged.py", line 123, in <listcomp>
    [ConnectorWithLinks.from_dict(_item) for _item in obj["data"]]
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kdanylov/venvs/speechy/lib/python3.11/site-packages/miro_api/models/connector_with_links.py", line 196, in from_dict
    "style": ConnectorStyle.from_dict(obj["style"]) if obj.get("style") is not None else None,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kdanylov/venvs/speechy/lib/python3.11/site-packages/miro_api/models/connector_style.py", line 215, in from_dict
    _obj = cls.model_validate(
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/kdanylov/venvs/speechy/lib/python3.11/site-packages/pydantic/main.py", line 532, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ConnectorStyle
endStrokeCap
  Value error, must be one of enum values ('none', 'stealth', 'diamond', 'filled_diamond', 'oval', 'filled_oval', 'arrow', 'triangle', 'filled_triangle', 'erd_one', 'erd_many', 'erd_only_one', 'erd_zero_or_one', 'erd_one_or_many', 'erd_zero_or_many') [type=value_error, input_value='unknown', input_type=str]
    For further information visit https://errors.pydantic.dev/2.7/v/value_error
    ````

Password limit 60 char is not implemented correctly

Hello everyone
Sorry did not found a better place to declare the bug please forward it to the right developer.
Your signin form has a minor bug :
image

it blocks 60 char password and accepts 59 char password,
it should accept 60 char password per the error message.

Also, it looks like once I triggered this bug, the error message stays even when I drop char from the password. Did not tried to reproduce that part though.

Shape/Widget type does not allow to access `style` attribute (when requested via Frame)

Widgets/Shapes

The REST api return the style information of a shape, but the mapped api client entity does not map it:

image

https://api.miro.com/v2/boards/{boardId}/items?parent_item_id=345876…

{
  "size": 10,
  "limit": 10,
  "total": 130,
  "data": [
    {
      "id": "xxxxx",
      "type": "shape",
      "data": {
        "content": "<p>foo bar</p>",
        "shape": "round_rectangle"
      },
      "geometry": {
        "width": 444.088581871232,
        "height": 732.1054958788144
      },
      "position": {
        "x": 1762.7907113951542,
        "y": 727.6837648015721,
        "origin": "center",
        "relativeTo": "parent_top_left"
      },
      "style": {
        "fillColor": "#fdedc0",
        "fillOpacity": "1.0",
        "fontFamily": "open_sans",
        "fontSize": "14",
        "borderColor": "#fad978",
        "borderWidth": "3.0",
        "borderOpacity": "1.0",
        "borderStyle": "normal",
        "textAlign": "center",
        "textAlignVertical": "middle",
        "color": "#1a1a1a"
      },
      
    },
  ],
  
  "type": "cursor-list"
}

[API spec] Dark colors break tags

The API only supports normal and light colors (green, lightgreen) but in the UI, you can use "dark green".

If you select this value, the server sends the value "unknown" for "fillColor" but the API doesn't support this value.

Please extend the API to support all 15 possible colors plus "unknown".

How to get Miro User ID during REST API authentication from Miro's Web SDK authorization

When following the REST API authentication from Miro's Web SDK authorization and using the api-client I'm having trouble finding the Miro User ID in time so I can look up my externalUserId.

In the normal API flow we would put the external ID in the state or the callback URL but in the app auth flow the redirect URL is sent by Miro based on a static field in the app settings so we can't add a unique state on each URL. If we use the exchangeCodeForAccessToken the Miro UserId is hidden. I need the Miro UserId to find my external ID in my database early in the process. I spoke to Joseph during his presentation at the Miro Developer Q/A in Discord and he thought exchangeCodeForAccessToken might be changed to return the Miro User ID like:

const { userId } = await miro.exchangeCodeForAccessToken(ExternalUserId, code)

although, I'm thinking I need the Miro UserId before I call exchangeCodeForAccessToken so I can look up and send my external ID to exchangeCodeForAccessToken.

We were hoping to deploy this week. If that change is made how soon could it be done? Is there a suggested workaround? Or should I call back to not using the api-client for the APP Auth flow?

Connector stroke cap missing - Python API

I was trying to use the python api to load the connectors from a board and I kept hitting validation errors on the stroke cap property. I changed all of the arrows to another type and it works. Seems like we are missing the stroke cap for the first type of arrow shown in the UI

Screenshot 2024-07-03 at 16 50 48

Validation Error:
Reads the input_value as "unknown"
image

might also be that the frontend is not sending this value correctly (unknown seems odd to be send as a value for the stroke cap), but counting the options in the UI we have 16 and in the code we only have 15

Example of the connector style payload
image

Typescript error, form-data

On a clean install of angular with this package typescript throws an error (only able to be solved with adding the allowSyntheticDefaultImports), is this intended?

Looking around on the form-data repo the maintainers states that it is a commonJS library,
import * as FormData from 'form-data', might solve this. But I have no clue how your build system is setup (for now ill use allowSyntheticDefaultImports)

npm list

├── __ngcc_entry_points__.json@ extraneous
├── @angular-devkit/[email protected]
├── @angular-eslint/[email protected]
├── @angular-eslint/[email protected]
├── @angular-eslint/[email protected]
├── @angular-eslint/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @capacitor/[email protected]
├── @capacitor/[email protected]
├── @capacitor/[email protected]
├── @capacitor/[email protected]
├── @capacitor/[email protected]
├── @capacitor/[email protected]
├── @ionic/[email protected]
├── @ionic/[email protected]
├── @mirohq/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @typescript-eslint/[email protected]
├── @typescript-eslint/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

ng version

Angular CLI: 14.2.6
Node: 16.18.0
Package Manager: npm 8.19.2
OS: win32 x64

Angular: 14.2.7
... common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.6
@angular-devkit/build-angular   14.2.6
@angular-devkit/core            14.2.6
@angular-devkit/schematics      14.2.6
@angular/cli                    14.2.6
@schematics/angular             14.2.6
rxjs                            6.6.7
typescript                      4.7.4

Cannot set cookies within custom storage

Issue Details:
I encountered an issue where I cannot set a cookie when using a custom storage with Redis.
When attempting to set the cookie within the set method, it only works if placed at the beginning of the method. However, it does not work if I place it at the end of the method (I don't get any error in console).

Steps to Reproduce:

  1. Run npx create-miro-app@latest command.
  2. Select Next.js framework with Web SDK and API client installed [WEB SDK & REST API].
  3. Choose Typescript.
  4. After project creation, implement a custom storage with a Redis backend following the guide at Miro Node.js - Implement Storage for Data Persistence.
  5. Attempt to set a cookie within the RedisStorage's set method.
  6. Navigate to http://localhost:3000 and click the "Login" button.
  7. Proceed through the steps to add the app to a Miro team.
  8. Upon redirection to http://localhost:3000, notice the "Login" button is still present, indicating the "miro_tokens" cookie was not set.

Code Example:
Below is the custom storage class:

const tokensCookie = "miro_tokens";

export class RedisStorage implements Storage {
  private redisClient: any;

  // Initiate a connection to the Redis instance.
  // On subsequent calls, it returns the same Redis connection
  async _getClient() {
    if (!this.redisClient) {
      const client = createClient();
      await client.connect();
      this.redisClient = client;
    }
    return this.redisClient;
  }

  // Return the state from Redis, if this data exists
  async get(userId: ExternalUserId) {
    const client = await this._getClient();
    const value = await client.get(userId.toString());
    if (!value) return undefined;
    return JSON.parse(value);
  }

  // Store the state in Redis.
  // If the state is undefined, the corresponding Redis key is deleted
  async set(userId: ExternalUserId, state: State | undefined) {
    // If I set the cookie here, it works as expected. But I'm not sure if I should set it before or after storing the state in Redis.

    const client = await this._getClient();

    // Delete the state, if it's undefined
    if (!state) {
      return await client.del(userId.toString());
    }

    // Store the state in Redis
    await client.set(userId.toString(), JSON.stringify(state));

    // BUG: If I set the cookie here, a response is already sent to the client (src/app/api/redirect/route.ts). I don't get any error, but the cookie is not set.
    cookies().set(tokensCookie, JSON.stringify(state), {
      path: "/",
      httpOnly: true,
      sameSite: "none",
      secure: true,
    });
  }
}

Repository Example:
For a specific example to reproduce the bug, refer to this repository (bug/miro-api branch).

Problem in the /api/redirect endpoint:
When a user clicks the 'Login' button, adds the app to a team and is redirected to the app, the following sequence occurs:

  1. Receive a request (/api/redirect endpoint).
  2. Extract the code from query parameters.
  3. Call the exchangeCodeForAccessToken method.
  4. The storage's set method is called. exchangeCodeForAccessToken is calling it.
  5. Redirect the user to "/".
  6. Save session data in Redis.
  7. Attempt to set a cookie (noted that the user already received a response without the cookie).

NOTE: the step 5 (Redirect the user to "/") must be the last step but user is being redirected before saving the session data in redis and setting the cookie

Root Cause Analysis:
After modifying the Miro class of the @mirohq/miro-api package found in the node_modules folder it is working as expected. It appears there is a missing await when calling the storage's set method in the getToken method.

Suggested Fix:
Consider adding an await in the getToken method of the Miro class, see the screenshot below. This change should be made in this file.

Screenshot

There is an await in the revokeToken method when calling storage's set method (Line 120), I think there should be an await when calling storage's set method in the getToken method (Line 134)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.