opral / lix-sdk

1 stars 0 forks source link

Dedicated `change_metadata` table #87

Closed samuelstroschein closed 1 month ago

samuelstroschein commented 1 month ago

Context

@samuel.stroschein said in LIXDK-169:

@martin.lysk1 yep you're right. the change.metadata field makes sense because APPS can add metadata to changes. I can implement change sets and tags via the metadata field without requiring lix to implement them 🤯 That entails though:

  • plugins DON'T report metadata (as they do right now), only snapshots
  • we should likely implement Metadata as own table due to the same insight as LIXDK-166)

Proposal

  1. metadata table.
table change {
   ...
-  meta: JSON
+  metadata_id: TEXT
}
table metadata {
  id: UUID_V7
  value: JSON
}
  1. Discourage/disallow plugins to set metadata (they report a snapshot)

cc @martin.lysk1 agree?

martin-lysk commented 1 month ago

@samuel.stroschein Just to be sure - Can you describe the difference between apps and plugins?

samuelstroschein commented 1 month ago

Plugins

Plugin detect changes and conflicts in file formats.

Apps

Provide a UI and functionality on top lix change control.

Difference

Plugins instruct lix on how to deal with file formats.

Good enough? We should add the definitions to the docs then

martin-lysk commented 1 month ago

Ok - in my own words:
A plugin is provided with the before and after states of a file and extracts all information that represents a snapshot of the entities within that file.

In case of a *.md file that could be the whole file (because we have no identifier but the file name).

In case of inlang the plugin compares two states of a sqlite file, extracts changed rows (each having a ID) and stores them as a snapshot.

-> Makes sense

What i don't understand is the role app's play here -
A Plugin does NOT(?) enrich the change information with metadata. What, why and when would apps store metadata than?

samuelstroschein commented 1 month ago

Good explanation although the explanation is specific to plugin.detectChanges. The generic description for a plugin would go along the lines of "A plugin provides lix with change information for a file format".

What i don't understand is the role app's play here -
​A Plugin does NOT(?) enrich the change information with metadata. What, why and when would apps store metadata than?

Easier to explain on a call.

TL;DR apps can enrich changes that have been reported by plugins however they need.

For example, the CSV app can implement change tags via change.metadata without support from the lix SDK as a workaround/test case.

It follows that plugins don't need metadata. They can report everything they know via the snapshot. Apps can't report and edit a snapshot though. Hence, they need the metadata field to add information to changes that a plugin didn't provide in the snapshot.

samuelstroschein commented 1 month ago

Cancelled.