diff --git a/src/lib/decode-conversions.ts b/src/lib/decode-conversions.ts index 1ac5732..192b8c4 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 || undefined, } } 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..753a1ef 100644 --- a/test/fixtures/bad-docs.js +++ b/test/fixtures/bad-docs.js @@ -16,6 +16,7 @@ export const badDocs = [ schemaName: 'observOtion', createdAt: cachedValues.createdAt, updatedAt: cachedValues.updatedAt, + createdBy: cachedValues.createdBy, links: [], refs: [], attachments: [], @@ -32,9 +33,27 @@ export const badDocs = [ schemaName: 'role', createdAt: cachedValues.createdAt, updatedAt: cachedValues.updatedAt, + createdBy: cachedValues.createdBy, links: [], roleId: '', fromIndex: 4, }, }, + { + text: 'doc with invalid value for `deleted` field', + doc: { + docId: cachedValues.docId, + versionId: cachedValues.versionId, + schemaName: 'observation', + createdAt: cachedValues.createdAt, + updatedAt: cachedValues.updatedAt, + createdBy: cachedValues.createdBy, + links: [], + refs: [], + attachments: [], + tags: {}, + metadata: {}, + deleted: false, + }, + }, ]