Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.0-rc38 #250

Merged
merged 5 commits into from
Jan 3, 2023
Merged

Release 2.0.0-rc38 #250

merged 5 commits into from
Jan 3, 2023

Conversation

Aschen
Copy link
Contributor

@Aschen Aschen commented Jan 3, 2023

2.0.0-rc38

Adrien Maret and others added 5 commits December 21, 2022 13:20
… more intuitive (#246)

## What does this PR do ?

Change `device-manager/devices:linkAsset` API action. The new format is specified in the type `ApiDeviceLinkAssetRequest`. The `measures` is not a table anymore but an array which each element describe a measure with it's `name` and `type` to avoid confusion between key/value.

```
  action: "linkAsset";

  _id: string;

  refresh?: string;

  assetId: string;

  body?: {
    /**
     * Names of the linked measures
     *
     * Array<{ asset: string, device: string }>
     *
     * @example
     *
     * [
     *   { asset: "externalTemperature", device: "temperature" }
     * ]
     */
    measureNames: Array<{ asset: string; device: string }>;
  };
```

The method to register default devices and array also changed accordingly (`Plugin.registerAsset` and `Plugin.registerDevice`).

The `assets` collection changed as well. `measures` become `measureNames` and have the same format as the parameter in the API action

The `models` collection mappings also changed, the `measures` property now have the same format as the parameter in the API action
Every change happening to an asset is now historized.

There is 4 categories of changes. After every change, a complete copy of the asset is saved into the `assets-history` collection. 

The document also contains additional informations about the change:
 - `measure`: asset receive a new measure (`event.measure.names` contains the name of the new updated measures)
 - `metadata`: metadata have been modified (`event.metadata.names` contains the name of the updated metadata)
 - `link`: a new device has been linked (`event.link.deviceId` contains the newly linked device ID)
 - `unlink`: a device has been unlinked (`event.unlink.deviceId` contains the unlinked device ID)
 
If metadata are updated during the measure ingestion pipeline, then the history document have both the `event.measure` and `event.metadata` properties.

<details><summary>Example of history document after receiving a measure</summary>

```
{
  "event": {
    "measure": {
      "names": [
        "temperatureExt"
      ]
    },
    "name": "measure"
  },
  "id": "Container-linked1",
  "asset": {
    "model": "Container",
    "reference": "linked1",
    "metadata": {
      "weight": 42042,
      "height": 11
    },
    "linkedDevices": [
      {
        "measureNames": [
          {
            "asset": "temperatureExt",
            "device": "temperature"
          }
        ],
        "_id": "DummyTemp-linked1"
      }
    ],
    "_kuzzle_info": {
      "updatedAt": 1672345639726,
      "updater": null
    },
    "measures": {
      "temperatureExt": {
        "measuredAt": 1672345639722,
        "name": "temperatureExt",
        "payloadUuids": [
          "267fe1a9-3d4f-4ad5-b4a8-383e38742b4e"
        ],
        "type": "temperature",
        "values": {
          "temperature": 42.2
        }
      }
    }
  }
}
```

</details>

### Other Changes

 - Use impersonated SDK in Assets and Devices controllers to preserve Kuzzle Metadata
Remove the action to push directly a measure to an asset.

This does not make sense anymore since all measure have to go through the measure ingestion pipeline starting with the Payload Controller.

Measures who were pushed using this controller have a good chance to be metadata that needed historization. Since this PR, #247, metadata changes are also historized.
@Aschen Aschen added the release label Jan 3, 2023
@Aschen Aschen merged commit fed1032 into 2-stable Jan 3, 2023
@Aschen Aschen deleted the 2-dev branch January 3, 2023 11:24
@Aschen Aschen restored the 2-dev branch January 3, 2023 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant