Skip to content

Commit

Permalink
refactor(backend): add entity ID to the document in the API
Browse files Browse the repository at this point in the history
  • Loading branch information
burdiyan committed Jul 27, 2023
1 parent 0c19b83 commit 3a9f6a7
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 133 deletions.
3 changes: 2 additions & 1 deletion backend/daemon/api/documents/v1alpha/document_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ func (dm *docModel) cleanupPatch() {
func (dm *docModel) hydrate(ctx context.Context, blobs *hyper.Storage) (*documents.Document, error) {
e := dm.e
docpb := &documents.Document{
Id: e.ID().TrimPrefix("hd://d/"),
Id: e.ID().TrimPrefix("hd://d/"),
Eid: string(e.ID()),
}

{
Expand Down
4 changes: 4 additions & 0 deletions backend/daemon/api/documents/v1alpha/documents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ func TestAPIUpdateDraft_Complex(t *testing.T) {

want := &documents.Document{
Id: draft.Id,
Eid: draft.Eid,
Author: draft.Author,
Editors: []string{draft.Author},
Title: "Hello Drafts V2",
Expand Down Expand Up @@ -372,6 +373,7 @@ func TestAPIUpdateDraft_Complex(t *testing.T) {

want := &documents.Document{
Id: draft.Id,
Eid: draft.Eid,
Author: draft.Author,
Editors: []string{draft.Author},
Title: "Hello Drafts V2",
Expand Down Expand Up @@ -422,6 +424,7 @@ func TestAPIUpdateDraft_Complex(t *testing.T) {

want := &documents.Document{
Id: draft.Id,
Eid: draft.Eid,
Author: draft.Author,
Editors: []string{draft.Author},
Title: "Hello Drafts V2",
Expand Down Expand Up @@ -570,6 +573,7 @@ func TestAPIUpdateDraft_WithList(t *testing.T) {

want := &documents.Document{
Id: draft.Id,
Eid: draft.Eid,
Title: "My new document title",
Author: draft.Author,
Editors: []string{draft.Author},
Expand Down
266 changes: 138 additions & 128 deletions backend/genproto/documents/v1alpha/documents.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,13 @@ export class Document extends Message<Document> {
*/
id = "";

/**
* Entity ID of the document.
*
* @generated from field: string eid = 12;
*/
eid = "";

/**
* Title of the document.
*
Expand Down Expand Up @@ -848,6 +855,7 @@ export class Document extends Message<Document> {
static readonly typeName = "com.mintter.documents.v1alpha.Document";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 12, name: "eid", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "title", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "author", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 10, name: "web_url", kind: "scalar", T: 9 /* ScalarType.STRING */ },
Expand Down
3 changes: 3 additions & 0 deletions proto/documents/v1alpha/documents.proto
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ message Document {
// Permanent ID of the document.
string id = 1;

// Entity ID of the document.
string eid = 12;

// Title of the document.
string title = 2;

Expand Down
4 changes: 2 additions & 2 deletions proto/documents/v1alpha/go.gensum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
srcs: 08fa35d79aad416cb79efde2e41830a1
outs: 424535f2838016dcfba650fddf70b40c
srcs: de8217901a48274b8593f7759db2cadc
outs: d250a84410ccddb51bd9836632f1d6a5
4 changes: 2 additions & 2 deletions proto/documents/v1alpha/js.gensum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
srcs: 08fa35d79aad416cb79efde2e41830a1
outs: a76a67f5ab3be2aced51d5a1f4b430dd
srcs: de8217901a48274b8593f7759db2cadc
outs: a278d13a7830b946855dde05f1c44881

0 comments on commit 3a9f6a7

Please sign in to comment.