diff --git a/proto/observation/v5.proto b/proto/observation/v5.proto index fe154b8..8f4c86a 100644 --- a/proto/observation/v5.proto +++ b/proto/observation/v5.proto @@ -29,7 +29,7 @@ message Observation_5 { audio = 2; } message Attachment { - bytes driveId = 1; + bytes driveDiscoveryId = 1; string name = 2; AttachmentType type = 3; bytes hash = 4; diff --git a/schema/observation/v5.json b/schema/observation/v5.json index 318860a..80fe82a 100644 --- a/schema/observation/v5.json +++ b/schema/observation/v5.json @@ -85,9 +85,9 @@ "items": { "type": "object", "properties": { - "driveId": { + "driveDiscoveryId": { "type": "string", - "description": "" + "description": "core discovery id for the drive that the attachment belongs to" }, "name": { "type": "string", @@ -106,7 +106,7 @@ "description": "SHA256 hash of the attachment" } }, - "required": ["driveId", "name", "type", "hash"] + "required": ["driveDiscoveryId", "name", "type", "hash"] } }, "tags": { diff --git a/src/lib/decode-conversions.ts b/src/lib/decode-conversions.ts index d4187a3..2338946 100644 --- a/src/lib/decode-conversions.ts +++ b/src/lib/decode-conversions.ts @@ -55,14 +55,16 @@ export const convertObservation: ConvertFunction<'observation'> = ( ...jsonSchemaCommon, ...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'), + attachments: message.attachments?.map( + ({ driveDiscoveryId, name, type, hash }) => { + return { + driveDiscoveryId: driveDiscoveryId.toString('hex'), + name, + type, + hash: hash.toString('hex'), + } } - }), + ), tags: convertTags(message.tags), metadata: message.metadata || {}, } diff --git a/src/lib/encode-conversions.ts b/src/lib/encode-conversions.ts index 9c58b41..b3c60db 100644 --- a/src/lib/encode-conversions.ts +++ b/src/lib/encode-conversions.ts @@ -80,7 +80,7 @@ export const convertObservation: ConvertFunction<'observation'> = ( }) const attachments = mapeoDoc.attachments.map((attachment) => { return { - driveId: Buffer.from(attachment.driveId, 'hex'), + driveDiscoveryId: Buffer.from(attachment.driveDiscoveryId, 'hex'), name: attachment.name, type: attachment.type, hash: Buffer.from(attachment.hash, 'hex'), diff --git a/test/fixtures/cached.js b/test/fixtures/cached.js index c30d9a4..ecb9e3c 100644 --- a/test/fixtures/cached.js +++ b/test/fixtures/cached.js @@ -12,7 +12,7 @@ export const cachedValues = { createdAt: date, updatedAt: date, attachments: { - driveId: randomBytes(32).toString('hex'), + driveDiscoveryId: randomBytes(32).toString('hex'), hash: randomBytes(32).toString('hex'), }, metadata: { diff --git a/test/fixtures/good-docs-completed.js b/test/fixtures/good-docs-completed.js index 1af6fa5..f88bd50 100644 --- a/test/fixtures/good-docs-completed.js +++ b/test/fixtures/good-docs-completed.js @@ -25,7 +25,7 @@ export const goodDocsCompleted = [ { name: 'myFile', type: 'photo', - driveId: cachedValues.attachments.driveId, + driveDiscoveryId: cachedValues.attachments.driveDiscoveryId, hash: cachedValues.attachments.hash, }, ],