diff --git a/proto/common/v1.proto b/proto/common/v1.proto index 1e3b62c..ac54704 100644 --- a/proto/common/v1.proto +++ b/proto/common/v1.proto @@ -16,6 +16,7 @@ message Common_1 { google.protobuf.Timestamp updatedAt = 4 [(required) = true]; // 32-byte hash of the discovery key of a core bytes createdBy = 5 [(required) = true]; + bool deleted = 6 [(required) = true]; } /* ignored fields and differences from common.json jsonSchema * id is a byte buffer here and a string in jsonSchema diff --git a/schema/common/v1.json b/schema/common/v1.json index de9c91a..0f439b4 100644 --- a/schema/common/v1.json +++ b/schema/common/v1.json @@ -38,6 +38,10 @@ "items": { "type": "string" } + }, + "deleted": { + "description": "Indicates whether the document has been deleted", + "type": "boolean" } }, "required": [ @@ -47,6 +51,7 @@ "updatedAt", "links", "versionId", - "createdBy" + "createdBy", + "deleted" ] } diff --git a/src/lib/decode-conversions.ts b/src/lib/decode-conversions.ts index 1ac5732..d4187a3 100644 --- a/src/lib/decode-conversions.ts +++ b/src/lib/decode-conversions.ts @@ -56,7 +56,12 @@ export const convertObservation: ConvertFunction<'observation'> = ( ...rest, refs: message.refs?.map(({ id }) => ({ id: id.toString('hex') })), attachments: message.attachments?.map(({ driveId, name, type, hash }) => { - return { driveId: driveId.toString('hex'), name, type, hash: hash.toString('hex') } + return { + driveId: driveId.toString('hex'), + name, + type, + hash: hash.toString('hex'), + } }), tags: convertTags(message.tags), metadata: message.metadata || {}, @@ -251,5 +256,6 @@ function convertCommon( createdAt: common.createdAt, updatedAt: common.updatedAt, createdBy: common.createdBy.toString('hex'), + deleted: common.deleted, } } diff --git a/src/lib/encode-conversions.ts b/src/lib/encode-conversions.ts index 4df1ae9..9c58b41 100644 --- a/src/lib/encode-conversions.ts +++ b/src/lib/encode-conversions.ts @@ -141,6 +141,7 @@ function convertCommon( updatedAt: common.updatedAt, createdBy: Buffer.from(common.createdBy, 'hex'), links: common.links.map((link) => parseVersionId(link)), + deleted: common.deleted, } } diff --git a/test/fixtures/bad-docs.js b/test/fixtures/bad-docs.js index 72b7db3..018af7c 100644 --- a/test/fixtures/bad-docs.js +++ b/test/fixtures/bad-docs.js @@ -16,11 +16,13 @@ export const badDocs = [ schemaName: 'observOtion', createdAt: cachedValues.createdAt, updatedAt: cachedValues.updatedAt, + createdBy: cachedValues.createdBy, links: [], refs: [], attachments: [], tags: {}, metadata: {}, + deleted: false, }, }, { @@ -32,9 +34,11 @@ export const badDocs = [ schemaName: 'role', createdAt: cachedValues.createdAt, updatedAt: cachedValues.updatedAt, + createdBy: cachedValues.createdBy, links: [], roleId: '', fromIndex: 4, + deleted: false, }, }, ] diff --git a/test/fixtures/good-docs-completed.js b/test/fixtures/good-docs-completed.js index 3b00265..1af6fa5 100644 --- a/test/fixtures/good-docs-completed.js +++ b/test/fixtures/good-docs-completed.js @@ -66,6 +66,7 @@ export const goodDocsCompleted = [ networkAvailable: false, }, }, + deleted: false, }, expected: {}, }, @@ -86,6 +87,7 @@ export const goodDocsCompleted = [ relation: cachedValues.defaultPresets.point, }, name: 'myProject', + deleted: false, }, expected: {}, }, @@ -110,6 +112,7 @@ export const goodDocsCompleted = [ value: 'somePrimitiveTagValue', }, ], + deleted: false, }, expected: {}, }, @@ -137,6 +140,7 @@ export const goodDocsCompleted = [ fieldIds: cachedValues.fieldIds, iconId: cachedValues.iconId, terms: ['imastring'], + deleted: false, }, expected: {}, }, @@ -151,6 +155,7 @@ export const goodDocsCompleted = [ links: [], roleId: '6fd029a78243', fromIndex: 5, + deleted: false, }, expected: {}, }, @@ -164,6 +169,7 @@ export const goodDocsCompleted = [ createdBy: cachedValues.createdBy, links: [], name: 'my device name', + deleted: true, }, expected: {}, }, @@ -189,6 +195,7 @@ export const goodDocsCompleted = [ blobIndex: Buffer.from('blobIndex'), }, identitySignature: Buffer.from('identity'), + deleted: true, }, expected: {}, }, diff --git a/test/fixtures/good-docs-minimal.js b/test/fixtures/good-docs-minimal.js index 1ea78da..2a968b5 100644 --- a/test/fixtures/good-docs-minimal.js +++ b/test/fixtures/good-docs-minimal.js @@ -24,6 +24,7 @@ export const goodDocsMinimal = [ attachments: [], tags: {}, metadata: {}, + deleted: false, }, expected: {}, }, @@ -36,6 +37,7 @@ export const goodDocsMinimal = [ updatedAt: cachedValues.updatedAt, createdBy: cachedValues.createdBy, links: [], + deleted: false, }, expected: {}, }, @@ -51,6 +53,7 @@ export const goodDocsMinimal = [ tagKey: 'myTagKey', label: 'my label', type: 'text', + deleted: false, }, expected: {}, }, @@ -70,6 +73,7 @@ export const goodDocsMinimal = [ removeTags: {}, fieldIds: [], terms: [], + deleted: false, }, expected: {}, }, @@ -84,6 +88,7 @@ export const goodDocsMinimal = [ links: [], roleId: '3b0104e370f9', fromIndex: 5, + deleted: false, }, expected: {}, }, @@ -97,6 +102,7 @@ export const goodDocsMinimal = [ createdBy: cachedValues.createdBy, links: [], name: 'my device name', + deleted: false, }, expected: {}, }, @@ -122,6 +128,7 @@ export const goodDocsMinimal = [ blobIndex: Buffer.from('blobIndex'), }, identitySignature: Buffer.from('identity'), + deleted: true, }, expected: {}, },