Skip to content

[Consistency] security:searchUsers method should return the same response than the one from the API #604

@Njuelle

Description

@Njuelle

Expected Behavior

When calling the security:searchUsers method with the SDK, the response must be consistent with the API :

{
  "status": 200,
  "error": null,
  "action": "searchUsers",
  "controller": "security",
  "requestId": "<unique request identifier>",
  "result": {
    "total": 2,
    "hits": [
      {
        "_id": "kuid1",
        "_source": {
          // User content
        }
      },
      {
        "_id": "kuid2",
        "_source" {
          // User content
        }
      }
    ]
  }
}

Current Behavior

Currently the SDK returns a user's information in the content object instead of _source :

{
    aggregations: undefined,
    hits:
      [ User { _kuzzle: [Kuzzle], _id: 'user2', content: [Object] },
        User { _kuzzle: [Kuzzle], _id: 'user1', content: [Object] },
        User { _kuzzle: [Kuzzle], _id: 'user3', content: [Object] } ],
    fetched: 3,
    total: 3 
}

Possible Solution

Add the _source object to the response and keep the content object as a reference of the first one to avoid breaking change.
The content object should be deprecated.

Bonus : Throw a warning only in dev mode to prevent that the content object is deprecated

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions