Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/36350-publish-draft-pin-client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@object-ui/data-objectstack': patch
---

feat(data-objectstack): `MetadataClient.publish` sends `draftVersion`; `updateView` pins its draft write to the draft it read

Clause-②: yes (widening)
Metadata-protocol: added

`MetadataClient.publish(type, name, options)` takes an optional `draftVersion` and sends it in the publish body beside `message`, pinning the promotion to that draft (`409 METADATA_CONFLICT` when the draft moved). Omitted, the body carries no such key and the publish is unpinned, as before.

`ObjectStackAdapter.updateView` (Manage views' Rename, Pin and Set as Default) reads a pending draft through `MetadataClient.getDraft`, whose answer carries the draft's `version`, before the layered read it merges from, and writes the merged draft pinned to it (`If-Match`, or `If-None-Match: *` when the read found no draft). A draft another writer changed in between is refused `409 METADATA_CONFLICT` and `updateView` throws the refusal instead of merging over a body it never read. A server whose draft read carries no `version` gets the unpinned write it got before.
11 changes: 11 additions & 0 deletions .changeset/36350-publish-draft-pin-console.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@object-ui/app-shell': patch
'@object-ui/console': patch
---

fix(app-shell, console): "Save to this view" and the runtime draft bar's Publish publish only the draft they mean

Clause-②: yes (widening)
Metadata-protocol: added

"Save to this view" (and every save that publishes at once, `saveAndPublishRuntimeMetadata`) pins its publish to the draft its own draft write returned. When another admin's rename, pin or set-default lands on the same view between that draft write and the publish, the publish is refused, nothing is published, and the draft, which now holds that other change, stays pending for review instead of being discarded; the save answers as it does over a draft found pending. The runtime draft bar's Publish is pinned to the draft the bar read and shows: a draft changed since is refused with the server's message and stays pending. Against a server that serves no draft version, both publish unpinned, as before.
10 changes: 10 additions & 0 deletions .changeset/36350-publish-draft-pin-protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/metadata-protocol': patch
---

feat(metadata-protocol): `publishMetaItem` refuses a draft that moved since the caller's `draftVersion`

Clause-②: yes (widening)
Metadata-protocol: added

`publishMetaItem` reads `draftVersion` (`PublishMetaItemRequestSchema.draftVersion`) and judges it against the draft row the promotion reads, before any authoring rule judges that draft: a token that is not that row's, or a pinned draft that is no longer pending, is refused `409 METADATA_CONFLICT` naming the draft's current token as `currentVersion`, with nothing promoted and the optimistic-conflict audit row recorded as for the other publish conflicts. The promotion stays locked to the same row through the write. Absent, any pending draft is promoted, as before; `parentVersion` still pins the active row.
10 changes: 10 additions & 0 deletions .changeset/36350-publish-draft-pin-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/rest': patch
---

feat(rest): `POST /meta/:type/:name/publish` takes `draftVersion` in its body, the pin on the draft it promotes

Clause-②: yes (widening)
Metadata-protocol: added

The per-item publish door reads an optional `draftVersion` member from its JSON body, beside `message`, and forwards it to the promotion: a draft that moved since that version (another writer's draft save landing between a caller's draft write and its publish) is refused `409 METADATA_CONFLICT` with the draft's current version as `currentVersion`, and nothing is published. A present `draftVersion` that is not a string is refused `400 VALIDATION_ERROR` instead of being read as absent. `If-Match` / `If-None-Match: *` keep pinning the active row, as before.
14 changes: 14 additions & 0 deletions .changeset/36350-publish-draft-pin-spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/spec': minor
---

feat(spec): `PublishMetaItemRequestSchema` declares `draftVersion`, the per-item publish's pin on the draft it promotes

Clause-②: yes (widening)
Metadata-protocol: added

`PublishMetaItemRequestSchema` (the request of `POST /api/v1/meta/:type/:name/publish`) gains one optional member, `draftVersion`: the version token of the pending draft the caller wrote or read and means to publish (a draft save's receipt `version`, or the strict draft read's `version`). On the REST door it is the `draftVersion` member of the publish body, beside `message`. A token that is not the current draft row's is refused `409 METADATA_CONFLICT`, whose `currentVersion` names the draft's current token (`null` when no draft is pending), and nothing is promoted. Absent, the publish promotes whichever draft is pending, as before.

`parentVersion` (`If-Match` on the REST door) keeps its meaning: it pins the active row the promotion replaces. The two judge different rows and may be sent together.

Nothing to migrate: a caller that does not send the member is unaffected.
5 changes: 3 additions & 2 deletions content/docs/references/api/protocol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,7 @@ The authoring surface of a metadata write. Closed: `copilot` is an AI assistant'
| :--- | :--- | :--- | :--- |
| **error** | `string` | ✅ | Human-readable refusal sentence, unchanged by `currentVersion`: it names the item and the version the door judged current. For display and logs; branch on `code` and read `currentVersion`, never parse this. |
| **code** | `'METADATA_CONFLICT'` | ✅ | ADR-0112 registered code of the optimistic-lock refusal. |
| **currentVersion** | `string \| null` | ✅ | The version token of the head the door judged current — the value the sentence names — or `null` when no row of the target lifecycle exists. Send it as `If-Match` to overwrite deliberately (or `If-None-Match: *` when it is `null`), or re-read the item to merge first. A `null` for an item whose read serves `editable: false` prescribes no pin: that item takes no save. Opaque — echo it verbatim, never parse it. |
| **currentVersion** | `string \| null` | ✅ | The version token of the head the door judged current — the value the sentence names — or `null` when no row of the target lifecycle exists. Send it as `If-Match` to overwrite deliberately (or `If-None-Match: *` when it is `null`), or re-read the item to merge first. A `null` for an item whose read serves `editable: false` prescribes no pin: that item takes no save. On the per-item publish door a refused `draftVersion` names the DRAFT's current token instead: send it back as `draftVersion` in the publish body (never as `If-Match`, which pins the active row), and there `null` means no draft is pending — nothing is left to publish. Opaque — echo it verbatim, never parse it. |


---
Expand Down Expand Up @@ -2660,7 +2660,8 @@ The authoring surface of a metadata write. Closed: `copilot` is an AI assistant'
| **message** | `string` | optional | Optional human-readable note recorded with the publish history event. |
| **packageId** | `string \| null` | optional | ADR-0048 — the software package the draft being promoted was listed under, when the caller has one to state (`?package=<id>` on the REST door). Named, the publish promotes that package's draft and no other. ABSENT names no package: the publish promotes the draft a draft save that names no package writes — the draft of the one package the item's active rows are bound to, else its package-unbound draft, promoted into that package — and answers `404 NO_DRAFT` when neither exists, as the strict draft read does. For an item never published into a package it is the package-unbound draft, else the one package's draft. It is refused `409 RESOURCE_CONFLICT` when the active rows (or, with none and no package-unbound draft, the drafts) are bound to two or more packages, except a bundled type's member whose active rows a base package and a package declaring it both hold, with no package-unbound row beside them: the read naming no package serves the base's row, and the publish promotes the base's draft into it, as naming the base does (two packages neither of which declares the other are still refused). ⚠️ `null` is NOT the same as absent: the implementation branches on the KEY BEING PRESENT, and `null` pins the lookup to the package-UNBOUND row. Spread it in conditionally; a present-and-`undefined` key coerces to `null` downstream and makes a package-bound draft unfindable — a silent `no_draft`. |
| **member** | `string` | optional | Bundle member selector, for a metadata type whose identity is a pair (today only `email_template`, identified by `(name, locale)`): the member this request addresses, spelled as its discriminator value (`zh-CN`). Absent, the canonical member (`en-US` for `email_template`), which is what a bare-name read answers; naming the canonical value is the same request. It is not the response translation locale, which `?locale=` and `Accept-Language` choose. Refused with 400 `VALIDATION_ERROR` on a type that has no members, and for a blank value or one longer than a stored member can be (100 characters). A well-formed member with nothing stored or shipped answers as that door answers an absent item. |
| **parentVersion** | `string \| null` | optional | ADR-0008 optimistic-concurrency pin on the PUBLISHED layer: the version token of the active row the caller loaded and means to replace (on the REST door, the `If-Match` request header; the `/layers` read's `overlayVersion`, the plain read's `version` and a publish receipt's `version` serve it). A token that is not the current active row's at the address the promotion writes is refused 409 `METADATA_CONFLICT`, whose `currentVersion` names the active row's current token, and nothing is promoted: the draft stays pending. ⚠️ `null` is NOT the same as absent: a present `null` asserts "no active row here" (on the REST door, `If-None-Match: *`, which takes `*` alone and never beside `If-Match`), refused 409 when one exists; an ABSENT key is unpinned and promotes over whatever is live, as before. It pins the active row only — which draft is promoted is the address's, as without it. |
| **parentVersion** | `string \| null` | optional | ADR-0008 optimistic-concurrency pin on the PUBLISHED layer: the version token of the active row the caller loaded and means to replace (on the REST door, the `If-Match` request header; the `/layers` read's `overlayVersion`, the plain read's `version` and a publish receipt's `version` serve it). A token that is not the current active row's at the address the promotion writes is refused 409 `METADATA_CONFLICT`, whose `currentVersion` names the active row's current token, and nothing is promoted: the draft stays pending. ⚠️ `null` is NOT the same as absent: a present `null` asserts "no active row here" (on the REST door, `If-None-Match: *`, which takes `*` alone and never beside `If-Match`), refused 409 when one exists; an ABSENT key is unpinned and promotes over whatever is live, as before. It pins the active row only — which draft is promoted is the address's, as without it; the draft's own pin is `draftVersion`. |
| **draftVersion** | `string` | optional | ADR-0008 optimistic-concurrency pin on the DRAFT this publish promotes: the version token of the pending draft row the caller wrote or loaded and means to publish (on the REST door, the `draftVersion` member of the publish body, beside `message`; a draft save's receipt `version` and the draft read's `version` serve it). A token that is not the current draft row's at the address the promotion reads is refused 409 `METADATA_CONFLICT`, whose `currentVersion` names the draft's current token (`null` when no draft is pending), and nothing is promoted: a draft another writer changed after the caller wrote or read it is never published on that writer's behalf. ABSENT is unpinned and promotes whichever draft is pending, as before. It pins the draft only — the active row the promotion replaces is `parentVersion`'s (`If-Match`), and the two may be sent together: the draft is judged first, so a request stale on both is refused naming the draft's token. The address is resolved before either pin: no draft at the address while another package holds one answers `404 NO_DRAFT`, not this conflict. |
| **userTextLocales** | `string[]` | optional | The locales the user-facing sentences of this write's findings (`advisories[].userMessage`, and `issues[].userMessage` on its 422) are composed in, in ladder order: the locale the request names, then the workspace default. Each is read against the platform locale table, whole and then one subtag shorter at a time; a value that names no table language is passed over, and `en` is the last rung. Stated by the door that holds the request (the REST door and the dispatcher state `[ExecutionContext.locale, ExecutionContext.workspaceLocale]`), never read from a wire body. ABSENT ⇒ the sentences are composed in `en`. It selects a language only: what is judged, refused or saved does not depend on it. |


Expand Down
14 changes: 14 additions & 0 deletions packages/metadata-protocol/src/protocol-door-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ type PublishMetaItemRequest = {
member?: string;
/** [#32656] The locales the findings' user sentences are composed in (`PublishMetaItemRequestSchema.userTextLocales`). */
userTextLocales?: readonly (string | undefined)[];
/**
* [#36601] The caller's pin on the active row this promotion replaces
* (`PublishMetaItemRequestSchema.parentVersion`): a token, `null` for "no
* active row here", absent for unpinned.
*/
parentVersion?: string | null;
/**
* [#36350] The caller's pin on the draft this promotion reads
* (`PublishMetaItemRequestSchema.draftVersion`): a token, absent for
* unpinned. Declared here, not only on the promotion's own parameter, so a
* typed in-process caller can state it and an edit that picks members
* instead of spreading the request cannot drop it unseen.
*/
draftVersion?: string;
};

/** The request of {@link ObjectStackProtocolImplementation.rollbackMetaItem}. */
Expand Down
Loading
Loading