MILAB-6817: make project templates first-class entities - #1797
Open
AStaroverov wants to merge 2 commits into
Open
MILAB-6817: make project templates first-class entities#1797AStaroverov wants to merge 2 commits into
AStaroverov wants to merge 2 commits into
Conversation
A template stops being a file you export and becomes an object stored on the server next to projects. - UserTemplate resource: the template-v1 document in the immutable data blob, the mutable label and timestamps in KV, listed through a Templates resource the same way projects are. - saveProjectAsTemplate, renameTemplate, deleteTemplate, resolveTemplate and createProjectFromTemplate on MiddleLayer. Applying resolves and prepares every entry before it creates the project, so a template that cannot be built in full leaves nothing behind. - Template sharing: EnvelopeData carries a discriminated payload and moves to schemaVersion 2, a v1 envelope still decodes as a project share, and an envelope whose payload kind is unknown is hidden rather than offered. A template share is granted read-only and is refused outright while any entry is installed from a folder on the author's machine. - Accepting a template share puts a template on the recipient's shelf and creates no project.
🦋 Changeset detectedLatest commit: 4ea0a55 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1797 +/- ##
==========================================
+ Coverage 53.07% 54.34% +1.26%
==========================================
Files 412 418 +6
Lines 21248 21895 +647
Branches 4744 4889 +145
==========================================
+ Hits 11277 11898 +621
+ Misses 8616 8559 -57
- Partials 1355 1438 +83 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes project templates first-class entities in the middle layer: stored in the user's root, listed like projects, and shareable.
What a template is now
template-v1document lives in an ephemeral resource's data blob; the mutable label and timestamps live in KV. Nothing that can change is inside the document, so the document is never rewritten.Templatesresource under the user's root, listed and watched the same way the project list is (template_list.ts: pruning function, field filter, computable).saveProjectAsTemplate,renameTemplate,deleteTemplate,getTemplateData,resolveTemplate,createProjectFromTemplate,applyTemplateToProject,shareTemplate.applyTemplateToProjectis split intoprepareTemplateEntries+applyPreparedEntries: every entry is resolved before anything is created, so a template that cannot resolve produces no project rather than a partial one.Sharing
EnvelopePayloadbecomes a discriminated union —{ kind: "projects" }|{ kind: "template" }— andEnvelopeData.schemaVersiongoes 1 → 2.lockInputs, no writable grant) and writes noacceptance/{login}receipt: the recipient gets the document on their own shelf and decides when to apply it, so there is no acceptance to report back.OutgoingShare.responsesAvailablesays so.createPendingSharesComputablerecognises-or-hides: a payload kind the client does not know is hidden rather than mis-rendered.Tests
templates.test.ts— the shelf: create, rename, delete, list.template_share.test.ts,sharing_model.test.ts— envelope building and the payload discriminant.template-round-trip.test.ts(drivers-ml-blocks-integration) — save a project as a template, share it, accept it, build a project from it.Notes for the reviewer
schemaVersionbump alone: the shipped v1 client has no version or kind check, so it will see a template share as a project share. The recognise-or-hide logic protects clients from this PR onward only.changeSharecannot re-point a template share yet — the templateId is not part of the change path.Desktop side: milaboratory/platforma-desktop-app#535
Greptile Summary
The PR promotes project templates to persistent, listable, applicable, and shareable middle-layer entities while extending sharing envelopes with discriminated payloads and backward-compatible version-1 decoding.
UserTemplate; newly introduced as the template-operation key.payload, while version 1 is upcast on read.Confidence Score: 5/5
The PR appears safe to merge; no unacknowledged blocking or independently actionable non-blocking defect was established.
The template shelf, payload-aware sharing paths, compatibility normalization, and resolution-first application are internally coordinated and covered by focused and integration tests; the remaining empty-project exceptional path is already explicitly documented for follow-up.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR Project[Project] -->|saveProjectAsTemplate| Template[Stored UserTemplate] Template --> Shelf[Templates shelf] Template -->|resolve and prepare| Prepared[Prepared entries] Prepared -->|create and apply| NewProject[New project] Template -->|shareTemplate| Envelope[Read-only template envelope] Envelope -->|grant| Recipient[Recipient] Recipient -->|acceptShare| RecipientShelf[Recipient template shelf] RecipientShelf -->|createProjectFromTemplate| RecipientProject[Recipient project]Reviews (1): Last reviewed commit: "MILAB-6817: add changeset for the templa..." | Re-trigger Greptile
Context used: