Skip to content

Commit

Permalink
chore!: rename Attachment.driveId to Attachment.driveDiscoveryId (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 authored Sep 27, 2023
1 parent 116db1a commit 7168f76
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion proto/observation/v5.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions schema/observation/v5.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -106,7 +106,7 @@
"description": "SHA256 hash of the attachment"
}
},
"required": ["driveId", "name", "type", "hash"]
"required": ["driveDiscoveryId", "name", "type", "hash"]
}
},
"tags": {
Expand Down
16 changes: 9 additions & 7 deletions src/lib/decode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {},
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/encode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/cached.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/good-docs-completed.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const goodDocsCompleted = [
{
name: 'myFile',
type: 'photo',
driveId: cachedValues.attachments.driveId,
driveDiscoveryId: cachedValues.attachments.driveDiscoveryId,
hash: cachedValues.attachments.hash,
},
],
Expand Down

0 comments on commit 7168f76

Please sign in to comment.