Skip to content

Resource Versioning Profile #1333

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

Open
wants to merge 27 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
df9838a
Create resource-versioning index.md.
gabesullice Dec 12, 2018
e815ccd
Add a "Resource Versioning" profile category
gabesullice Dec 13, 2018
c302a8c
Add all editors to this profile
gabesullice Dec 13, 2018
84d4840
Fix spacing
gabesullice Dec 13, 2018
ea9c13c
Use editor format from #1349
gabesullice Dec 20, 2018
9d9e263
move 501 to relative version section
gabesullice Dec 20, 2018
9368cbc
disambiguate bad version negotiator vs. argument errors
gabesullice Dec 20, 2018
d3c1d13
add trailing slash to error type URIs
gabesullice Dec 20, 2018
cac4baf
add linking and version history section
gabesullice Dec 20, 2018
56bc05e
fixup link and version history commit
gabesullice Dec 20, 2018
75659ce
add to and fix link example table
gabesullice Dec 20, 2018
2d5346e
typos and clarification
gabesullice Dec 20, 2018
c351d9c
change the query parameter from snake-case to camel-case
gabesullice Dec 20, 2018
3e4b67e
clarify that a one-segment version identifier is valid
gabesullice Dec 21, 2018
515aba9
invert definition of a version
gabesullice Dec 21, 2018
0feddd6
clarify the example narrative of a version history
gabesullice Dec 21, 2018
b0a1e3d
relax `type` link requirement
gabesullice Dec 21, 2018
f0d73db
clarify interoperability and optionality of version negotiators
gabesullice Dec 21, 2018
a4329d5
the first or only segment of a version identifier must be interpreted…
gabesullice Dec 21, 2018
7a352dc
restrict usage of the rel negotiator in resource objects' `self` links
gabesullice Dec 21, 2018
9129eb2
reduce redundancy
gabesullice Dec 21, 2018
ba9bf0b
use the `source` error object member in error details
gabesullice Dec 21, 2018
6bc95be
disallow custom rel-based version arguments
gabesullice Dec 21, 2018
1a1395d
reorder two lines
gabesullice Dec 21, 2018
e4adbd7
fix some ascii art
gabesullice Dec 21, 2018
5c5b0f4
fix italicization
gabesullice Dec 21, 2018
c82ecbe
update mateu's contact info
gabesullice Dec 21, 2018
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
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ quicklinks:

profile_categories:
- Pagination
- Resource Versioning
# these are some other potential categories.
# Uncomment them if you're adding a profile in one of these categories.
# - Filtering
Expand Down
301 changes: 301 additions & 0 deletions _profiles/drupal/resource-versioning/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
---
name: Resource Versioning
short_description: |
Defines a protocol for requesting versioned resources via a JSON:API
server.

extended_description: |
# Overview
JSON:API servers that are capable of tracking a record of changes to a
resource object may afford the capability of requesting a resource object
as it existed in a prior or successive state. This capability is herein
defined as _resource versioning_.

This profile establishes a protocol for resource versioning by defining a
query parameter and its semantics in order to identify arbitrary revisions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revisions → versions :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this instance, remember: "not all revisions are versions, but all versions are revisions"

of a resource and how a server should interpret this query parameter.

minimum_jsonapi_version: 1.0
minimum_jsonapi_version_explanation:

discussion_url: https://www.drupal.org/project/issues/jsonapi

editors:
- name: Gabriel Sullice
email: gabriel@sullice.com
- name: Mateu Aguiló Bosch
email: mateu@mateuaguilo.com
website: https://mateuaguilo.com
- name: Wim Leers
email: work@wimleers.com
website: https://wimleers.com

categories:
- Resource Versioning
---

# Concepts
Resources on a server may undergo changes and the state of a resource with an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that by "the state […] may be accessible", you mean that each state may be individually accessible?

arbitrary number of changes may be accessible. It is often useful to retrieve
resources as they existed at the time of their creation or in various states of
change for editorial or archival purposes. This profile establishes a protocol
for accessing resources in those various states.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is talking about previous states, for archival/history purposes. I think this should also explicitly state next states, i.e. drafts that are actively being worked on, or perhaps need to go through legal review, or are ready but simply aren't yet live because they're scheduled to be published in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is talking about previous states, for archival/history purposes.

I agree that this could be clarified, but I did not mean previous as you are interpreting it.

Even future revisions were created previously to now. They may not be the default version yet, but that does not mean that the revision itself was created in the future.


For the purpose of understanding this profile, it is helpful to establish a
vocabulary for describing various possible states of a resource.

A _revision_ is to be understood as an identifiable state of a resource after
its creation or after some number of changes.

A _version_ is to be understood as a revision that is or was the default
revision of a resource. In other words, as a revision of a resource that is
available, or was previously available, without any version negotiation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something like "that used to be the canonical representation, i.e. available without any version negotiation" would make this even more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very intentionally avoided the word "canonical" here because the canonical link relation is not intended to disambiguate revisions of a resource. It disambiguates duplicates of a resource when they have different URIs.


A _working copy_ is the revision to which new changes can be made or to which
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This term is specifically borrowed from
https://tools.ietf.org/html/rfc5829, because this entire profile was modeled after RFC5829. Linking to that at the top of the "Concepts" section would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I can't believe that I didn't already do that.

they will be applied. Colloquially, a working copy is often thought of as the
"tip" of a version history.

For example, a resource which existed as a draft and underwent multiple changes
before the resource was published may have many revisions. Only the published
revision would be considered a version. The revisions prior to first version
would have been known as the working copy as each one was created.

If the version is then checked out for further changes each new revision becomes
the working copy. When the working copy is checked in and made the default
revision, this revision becomes the latest version and the version before it is
its _predecessor version_. If no other revisions come after the latest version,
it may also be considered the working copy.

Sophisticated servers may support multiple versions of a resource as well as
multiple working copies of a resource (e.g., to support multiple
languages or within a version control system which supports multiple branches).

This profile creates a standard for JSON:API to support these diverse versioning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"these diverse" refers to both the "multiple versions" and "multiple working copies" in the preceding paragraph. Therefore I think it should be "diverse revisioning schemes", not "diverse versioning schemes"? (Because "versioning" refers only to versions, not to working copies.)

schemes.
# Query Parameter

## Usage

An endpoint **MAY** support a `resourceVersion` query parameter to allow a
client to indicate which version(s) of a resource should be returned.

If an endpoint does not support the `resourceVersion` parameter, it **MUST**
respond with `400 Bad Request` to any requests that include it. An error object
detailing the source of the error **SHOULD** include a `source` member referencing
the `resourceVersion` query parameter.

If an endpoint supports the `resourceVersion` parameter and a client supplies
it:

- The server’s response **MUST** contain the most appropriate version of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "the most appropriate" is unnecessarily vague. Can't we change the most appropiate version to the requested version?

resource requested.
- The server **MUST** respond with `404 Not Found` if an appropriate version of
the resource requested cannot be located.

> Note: This means that a server should not provide "fallbacks" unless the
> behavior is well defined by the version negotiation mechanism (see below).
> These rules apply to individual and collection endpoints alike.

## Format

The value of the `resourceVersion` parameter **MUST** be a colon-separated
(U+003A COLON, “:”) string composed of one or more segments. The first segment
of the string **MUST** be interpreted as an identifier for a _version negotiation
mechanism_. A version negotiation mechanism defines how a server will
locate an appropriate resource version. Subsequent segments of the string
**SHOULD** be interpreted as version negotiation arguments for the preceding
mechanism. Collectively, this query parameter value is known as the _version
identifier_.

> Note: For example, a server may support both ID-based and time-based
> mechanisms for requesting a resource version. The former mechanism would be
> useful for comparing versions and the latter could be useful for requesting a
> resource as it existed at an arbitrary point in time. This profile does not
> attempt to define every possible mechanism for versioning resources.

```
version-identifier
_______|________
/ \
?resourceVersion=rel:latest-version
\_/ \____________/
| |
version-negotiator |
version-argument
```

## Server Responsibilities

<a id="bad-version-negotiator"></a>A server **MUST** respond with `400 Bad Request` if a version negotiator is not
supported. An error object detailing the source of the error **SHOULD** include a
`type` link to
`https://jsonapi.org/profiles/drupal/resource-versioning/#bad-version-negotiator`
and **SHOULD** include a `source` member referencing the `resourceVersion` query
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at least one of these two **SHOULD**s should be come a **MUST**. Otherwise a 400 Bad Request response without any useful information is allowed, which is bad DX.

parameter.

<a id="bad-version-argument"></a>If a server cannot process the given version argument for the given negotiation
mechanism, it **MUST** respond with a `400 Bad Request`. An error object detailing the
source of the error **SHOULD** include a `type` link to
`https://jsonapi.org/profiles/drupal/resource-versioning/#bad-version-argument`
and **SHOULD** include a `source` member referencing the `resourceVersion` query
parameter.

If a server is able to process the version argument but an appropriate version
cannot be located, the server **MUST** respond with a `404 Not Found`.

# Links

When a server processes a request with a `resourceVersion` query parameter and
a `self` link is provided for a top-level links object, the link's `href`
**MUST** include the `resourceVersion` query parameter with the same version
identifier that was requested.

When a server processes a request with a `resourceVersion` query parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Design] My biggest piece of feedback about this profile is that it should probably also consider how to update resources (e.g., how to create a new working copy based of an existing one, or change the default version, or reject a PATCH if the resource's working copy has changed from the working copy that the client is trying to apply its PATCH to, etc). When resource versions have come up in the past, these updating use cases were actually the primary motivation, so not addressing them here would seem like a major missed opportunity that might be hard to remedy once this is published.

I've put this comment on this paragraph, though, because I think the considerations about updating bear directly on what the self link should be. If the self link is URL of a specific revision (as it seems to be here), then a PATCH to that link would be interpreted as updating the revision -- which should probably usually be immutable -- and creating a new revision would become a POST (or a patch to the default version's URL). So that's something to think about.

Also, if each revision is it's own HTTP resource (i.e., has its own URL), then the JSON:API id would usually be different for each revision too (e.g., so a PATCH actually could target the revision), though I suppose it wouldn't have to be. Distinct ids could cause lots of problems, though, because presumably only the default version's type/id would want to be used in relationship objects.

So this is all stuff to think about... I don't have any conclusions at the moment, but I'll mull it over, and hopefully you guys can too. I think, as usual, it goes back to the weird relationship that JSON:API resource objects have with HTTP's concepts of resources + entities.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which should probably usually be immutable

I think it makes sense to treat revisions as immutable.


I agree with all that was said in the comment above, but I want to highlight another implicit way of creating revisions that we may need to be explicit about.

Many frameworks handle revision creation as part of the store update. In Drupal when you save an entity that supports revisioning by PATCHing it (no resourceVersion used here), then a new revision will be created for you. You cannot do much about it in most of the cases. This new revision will be a working-copy or a version depending on some custom business logic (usually a published: true / false flag).

I guess that what I'm saying is that strict regulation of how revisions are created may become hard. However, we can put language on how to create revisions through JSON:API.

Where I'm going is, do we want this profile to include revision creation or it can be a separate profile?

Copy link
Contributor Author

@gabesullice gabesullice Dec 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Not] addressing [PATCH/DELETE] here would seem like a major missed opportunity that might be hard to remedy once this is published.

I think I agree.

Where I'm going is, do we want this profile to include revision creation or it can be a separate profile?

As above, I think I would like this profile to define how update/delete should be handled.


I think the considerations about updating bear directly on what the self link should be. If the self link is URL of a specific revision (as it seems to be here), then a PATCH to that link would be interpreted as updating the revision -- which should probably usually be immutable -- and creating a new revision would become a POST (or a patch to the default version's URL).

I think I may be in a minority about this, but I try to deeply appreciate the difference between a top-level self link and a resource object self link. I feel that once one groks what it means when they're different, the way JSON:API reconciles resource objects with HTTP resources + entities becomes much easier to think about.

Where I'm going with that is pretty simple: the top-level self link should be the URL used to mutate a resource object, not the resource object self link. Once you establish that, things become pretty simple.

GET /article/1?resourceVersion=rel:working-copy

{
  "data": {
    "type": "article",
    "id": 1,
    "links": {
      "self": "/article/1?resourceVersion=id:42"
    }
  },
  "links": {
    "self": "/article/1?resourceVersion=rel:working-copy"
  }
}

That means that a PATCH would update the working copy via the top-level self link, whatever it may be, like so:

PATCH /articles/1?resourceVersion=rel:working-copy

{
  "type": "article",
  "id": 1,
  "attributes": { // some changes }
}

The server response would then be:

200 OK

{
  "data": {
    "type": "article",
    "id": 1,
    "links": {
      "self": "/article/1?resourceVersion=id:43" // <- incremented
    }
  },
  "links": {
    "self": "/article/1?resourceVersion=rel:working-copy" // <- unchanged
  }
}

The working-copy link could be used instead of the top-level self link if the GET request was made directly to a resource object via an over-specific version negotiator (this would be the case if one visited /articles/1?resourceVersion=id:42 directly for some reason).

which should probably usually be immutable

I think it makes sense to treat revisions as immutable.

I think it makes sense too, but I don't think this profile needs to define that. I think it can work either way.

Drupal actually does permit updating a revision in-place (whether that's a good idea or not is beside the point 😛 ). With the scheme above, it would be possible for a server to support both in-place editing of a revision or new revision creation via PATCH depending on the self link used (top-level vs. resource object).

If a server cannot automatically create new revisions via PATCH for some reason (maybe it can't/hasn't implemented the rel negotiator), then I think the appropriate URL for creating new revisions would be at the version-history URL via POST. (this is why it makes sense for it to be a collection resource).

Copy link
Contributor Author

@gabesullice gabesullice Dec 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The language about updating resources in the spec seems to jive with what I suggested:

The URL for a resource can be obtained in the self link of the resource object. Alternatively, when a GET request returns a single resource object as primary data, the same request URL can be used for updates.

We could go a step further in that language by adding:

the same request URL or the top-level self link can be used for updates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @ethanresnick that the fact that this profile's narrowness (only defining "read" behavior) is its biggest weakness.

(Similarly, I think #824's biggest weakness also was its narrowness, it just was different: it focused on optimistic concurrency control.)

On the other hand, I think solid read-only support and leaving modifications to a separate profile or a future iteration is preferable over having a spec that supports fewer use cases (which I think was true of #824it did not allow a particular revision to be retrieved). Especially if it's based on another established standard (RFC5829) and therefore likely to be more implementation-agnostic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fascinated by @gabesullice's proposal (and the sample response bodies really help, thanks! 🙏). I'm very curious to find out what @ethanresnick thinks about that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or reject a PATCH if the resource's working copy has changed from the working copy that the client is trying to apply its PATCH to

I neglected to give a solid answer for this. As I said above, I think the PATCH should be sent to the top-level self link: /article/1?resourceVersion=rel:working-copy.

However, this spec could add something like an appliesToRevisionId: id:42 under the meta key of the request document.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reject a PATCH if the resource's working copy has changed from the working copy that the client is trying to apply its PATCH to

Support a conflict detection mechanism as described in initial review post wasn't discussed enough in my opinion. Something similar to AWS Amplify should be easy to achieve if already having well defined revisions. It was already discussed as part of #824 some time ago.

Maybe something like this would be everything needed:

Conflict detection when updating resources

A server SHOULD include the most specific version negotiator it supports in any resource object's meta information under revision key.
A client MAY include the revision an update is based on as under revision key of meta object on a PATCH request.
A server MUST reject 409 Conflict when processing a PATCH request to update a resource if a revision is provided as meta information, which is not the latest one.
A server MAY reject a PATCH request to update a resource if server has included a revision on retrieving the resource but the PATCH request does not include a revision.

all resource object `self` links **SHOULD** contain a `resourceVersion` query
parameter which identifies the specific revision represented by that resource
object.

A server **MUST** use the most specific version negotiator it supports for any
resource object `self` links that it provides.

For example, in the following response document the `self` links are not the
same:

```json
{
"data": {
"type": "article",
"id": 1,
"links": {
"self": "/article/1?resourceVersion=id:42"
}
},
"links": {
"self": "/article/1?resourceVersion=rel:latest-version"
}
}
```

A server **MAY** provide a `version-history` link in a resource object's links
object if a [version history](#version-history) endpoint is available for the context resource
object.

A server **MAY** provide the following resource object links so that a client may
navigate a resource object's version history:

- `latest-version`: links to the latest version of the context resource
object.
- `working-copy`: links to the working copy of the context resource object.
- `predecessor-version`: links to the version which immediately preceded the
context resource object.
- `successor-version`: links to the version which immediately succeeded the
context resource object.
- `prior-working-copy`: links to the working copy which immediately preceded
the context resource object.
- `subsequent-working-copy`: links to the working copy which immediately
preceded the context resource object.

A server **MAY** provide an array of any of these links to support branching.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethanresnick, this is in conflict with the base spec. Not sure what to do or how to accommodate this in any other way. Perhaps you have some ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabesullice I'd be happy to just define these links in the base spec as a temporary workaround. Note also that the base spec's current approach is that, if an array of links is allowed, an array should be required (like we did for profile) to not further proliferate the number of links cases that clients have to handle.

So, the base spec language would go under the resource links section, and could say something like:

If present, this object MAY also contain an array of links as the value for any of the following keys: latest-version, working-copy, predecessor-version, successor-version, [etc]. Links at any of these keys point to resources that are related to the resource object according to the IANA link relation corresponding to their key name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd be great :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethanresnick Rather than calling out those 4 specific link relations, perhaps it'd be better to generalize that to something like:

Links with a key that matches a registered link relation type which allows multiple values are allowed to have a value that is not a link, but an array of links.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I agree that calling out specific link relations "smells" a bit, I would not like to see the concept of links object keys as link relations furthered in the spec. Links can have more than one link relation and this pattern makes that more challenging to fix in later iterations of the spec.


For example, in the following version history:

```
_c_
/ \
/__b__d__ __f__ __h
/ \ / \ /
a e g
```

`g` is the latest version. Both `a` and `e` were previously the latest version.
No other revisions were ever the latest version. In this example, the following
links could be provided:

| Revision | `latest-version` | `working-copy` | `predecessor-version` | `successor-version` | `prior-working-copy` | `subsequent-working-copy` |
| :------: | :--------------: | :------------: | :-------------------: | :-----------------: | :------------------: | :-----------------------: |
| `a` | `g` | `h` | no link | `e` | no link | `b`, `c` |
| `b` | `g` | `h` | `a` | `e` | `a` | `c` |
| `c` | `g` | `h` | `a` | `e` | `b` | `d` |
| `d` | `g` | `h` | `a` | `e` | `b`, `c` | `e` |
| `e` | `g` | `h` | `a` | `g` | `d` | `f` |
| `f` | `g` | `h` | `e` | `g` | `e` | `g` |
| `g` | no link | `h` | `e` | no link | `f` | `h` |
| `h` | `g` | no link | `g` | no link | `g` | no link |

> Note: In this example, `f` has both a `predecessor-version` and
> `prior-working-copy` link to `e` because `e` was a version and `e` was also the
> revision to which changes could be applied prior to `f`'s creation.

# Version History

A server **MAY** provide a "version history" endpoint. The primary data
of a response document from a version history endpoint must be a collection of
resource objects.

Unless an `id` contains version information, the `type` and `id` members of each
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Spec compliance] Having multiple resource objects in data with the same type/id is sort of a spec violation. I say "sort of" because the spec technically says only that:

A compound document MUST NOT include more than one resource object for each type and id pair.

So, if this version history response isn't a compound document, you're technically in the clear. But the intent has always been that this restriction should apply to all responses. (I can't find the link for that now, but it's come up in conversations with @dgeb over the years.)

Note: I've also proposed removing the restriction altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not intended to be a compound document.

I don't think this profile can impose a requirement that ids contain version information. I think most systems store revision IDs separately from the entity ID. In our case, we use UUIDs for id and revision IDs are auto-incrementing integers. We'd have to make some wonky concatenation of these to put revision IDs into our resource object IDs and I don't think this profile should define how to do that.

I've been considering adding a recommendation that implementations add information to resource object's meta object that matches their most-specific version negotiator. For example, in our case (since we implement the id negotiator) we'd have:

{
  "type": "article",
  "id": "some-long-uuid",
  "meta": {
    "resourceVersionId": 42
  },
  "links": {
    "self": "/articles/some-long-uuid?resourceVersion=id:42"
  }
}

The rule would be something like:

It is RECOMMENDED that resource object's meta object contains a member whose name is resourceVersion appended by the upper-camel-cased name of the version negotiator used in the resource object's self link. The value of this member should be the the version identifier used in the resource object's self link, excluding its first segment, and it MUST NOT begin with a colon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just read the #824 PR. I like the idea of a revision key. This profile could adopt revision as a meta object member and require that it must be equal to the complete version identifier in a resource object's self link (or a valid one if a self link is not provided).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e0ipso @wimleers thoughts? ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also like a revision key (or version). This would also address @ethanresnick's "sort of" spec violation concern: if present, then it would be a higher specificity resource identifier (or perhaps even an intra resource identifier?): just like [type, id] uniquely identify a resource, [type, id, version] uniquely identifies a version of that resource.

Taking this further, there are multiple potential axes along which a variant of a resource can exist: version (or revision) is one, lang (or translation) is another. I think those are the two clearest, strongest use cases. It's possible to think of others though, such as localization.

I'd say versioning and translations are the two most common needs. I think we should keep both in mind if we're going to go this direction.

But for the sake for consistency and optionality (to ensure backwards compatibility & evolvability), I think we should consider not adding a version key, but a variant key. Under variant, this profile could then reserve the version key. A translation profile could reserve the translation key. This also opens the door for multiple versioning profiles if there is the need.

After having written this, I continued reading #824, to make sure I didn't miss anything. I think my variant proposal would actually address the "identity" concerns that @ethanresnick raised in
#824 (comment)? :)

Copy link
Contributor Author

@gabesullice gabesullice Jan 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crazy thought... maybe we could we extract a variant profile out of this profile? Re-minting resource_version as resource_variant. The "negotiation mechanism" would become the variant negotiation mechanism. Then you could have something like ?resource_variant=lang:en-US or resource_variant=revision:id:42 or ?resource_variant=revision:rel:working-copy.

In fact, if this variation scheme were part of the base spec, then revisions, translations, etc could just enhance that mechanism for its needs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wimleers noted very important thing. It's not enough to add version of the resource because each resource could have many translations and each translation could have it's own versions.

Copy link

@antonkomarev antonkomarev Feb 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Word locale could be considered for translation purposes instead of lang abbreviation.

resource object in the collection **MUST** be the same.

If provided, resource objects' `self` links **MUST NOT** be the same.

# Version Negotiators
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Design feedback/interoperable implementations review requirement] If I'm understanding correctly, each server implementation can define its own version negotiators, with multiple servers using the same negotiator name in different ways (and no central registry). That seems not great for interoperability. It would also seem to mean that no other version negotiators can ever be standardized as part of this profile, because they could conflict with existing implementations. Is that really what you want?

My gut instinct would be to make this profile's spec the canonical list of all legal version negotiators. Then, you can add more over time to this spec as they're requested. To support people who really need to use a version negotiator that isn't part of your profile, you could have some set of negotiator names/schemes/namespaces that are allowed to have implementation-specific meanings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I've done is applied the implementation-specific query parameter name constraints as a version negotiator constraint and added a mechanism for adding new negotiators to the profile.

Changes here: f0d73db

Elsewhere, @e0ipso suggest that we use URIs but I think this is sufficient. @e0ipso, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @wimleers cause it's his inbox that I suggested too 😛

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with that. However I still think that doc curies offer a lower barrier of entry. One could document the new crazy negotiator in their blog and have the server implementation point to that, instead of adding it here.

Many will just not go through the trouble to send their idea to some email addresses and be potentially blocked by them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I wanted to discourage non-standard negotiators being used as a standard and keep them isolated. My feeling was that sending an email saying "hey, I'd like to add a negotiator like this..." doesn't seem like a super high barrier. In some ways, it's even less difficult than opening a PR.

What if we add this:

Note: Don't be shy! New version negotiators are more than welcome, the editors want to see this profile proliferate and that means accepting versioning strategies like yours!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e0ipso, would that work?


This profile defines a number of version negotiators which a server **MAY**
implement. Additional version negotiator's may be added to this profile at a
later date.

Version negotiators which are not defined by this profile **MUST** adhere to the
same constraints as [implementation-specific query parameter names](https://jsonapi.org/format/1.1/#query-parameters-custom).

It is **RECOMMENDED** that any alternative version negotiators be added to this
profile. New version negotiators may be registered by sending one, joint email
to the profile editors with the subject line: "New JSON:API Resource Version
Negotiator: {negotiator name}". This will begin a process of refinement and/or
result in a determination of fitness for addition to this profile.

## ID-Based Version Negotiator

This profile establishes the `id` version negotiator. An `id`-based version
identifier is composed of two segments—the `id` version negotiator and a single
version argument. Any colons (U+003A COLON, “:”) present in the version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should say that the version argument is an opaque string.

identifier after the first occurrence **MUST** be interpreted as part of the
single version argument and **MUST NOT** be interpreted as a segment delimiter.

The resource version returned for any given version argument in an `id`-based
version identifier **MUST NOT** change over time.

> Note: This profile is agnostic about the format of the version argument in
> `id`-based version identifiers. For example, one server may use integers as
> revision IDs, another may use UUIDs and yet another may use content-based
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note could go away by defining it as an opaque string, like I suggested above.

> hashes.

## Relative Version Negotiator

This profile establishes the `rel` version negotiator. A `rel`-based version
identifier is composed of two or more segments. The first segment **MUST** be
`rel` and the following version arguments describe a resource version that is
relative to the version history.

The `rel` version negotiator **MUST NOT** appear in a resource object's `self` link.

The resource version returned for any given version argument in a `rel`-based
version identifier **MAY** change over time.

The `rel` version negotiator has the following valid version argument strings:

- `latest-version`: requests the latest default revision of a resource.
- `working-copy`: requests revision of a resource to which changes can be
made.

If any of the following version arguments is received in a `rel`-based version
identifier, the server **MUST** respond with a `501 Not Implemented`:

- `predecessor-version`
- `successor-version`
- `prior-working-copy`
- `subsequent-working-copy`

> Note: Future versions of this profile may define the behavior of these version
> arguments.

If any version argument is receieved other than the version arguments in this
section, a server **MUST** respond appropriately for a [bad version argument](#bad-version-argument).
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy