Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: rename Attachment.driveId to Attachment.driveDiscoveryId #147

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading