Skip to content

Commit

Permalink
chore!: remove refs property from schemas
Browse files Browse the repository at this point in the history
This isn't necessary for now, so we can remove it.

`refs` is still present for `Track`s.

Tested this with automated tests and by integrating it into
`@mapeo/core` with a temporary build of this module.
  • Loading branch information
EvanHahn committed Jul 22, 2024
1 parent f6d93ca commit 28d8777
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 31 deletions.
11 changes: 3 additions & 8 deletions proto/observation/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ message Observation_1 {
optional double lat = 5;
optional double lon = 6;

message Ref {
bytes id = 1;
}
repeated Ref refs = 7;

// ATTACHMENT
enum AttachmentType {
photo = 0;
Expand All @@ -34,10 +29,10 @@ message Observation_1 {
AttachmentType type = 3;
bytes hash = 4;
}
repeated Attachment attachments = 8;
repeated Attachment attachments = 7;

// TAGS
map<string, TagValue_1> tags = 9;
map<string, TagValue_1> tags = 8;

// METADATA
message Metadata {
Expand Down Expand Up @@ -69,5 +64,5 @@ message Observation_1 {
optional Position lastSavedPosition = 4;
optional PositionProvider positionProvider = 5;
}
optional Metadata metadata = 10;
optional Metadata metadata = 9;
}
16 changes: 1 addition & 15 deletions schema/observation/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,6 @@
"minimum": -180,
"maximum": 180
},
"refs": {
"type": "array",
"description": "References to any nodes or ways that this observation is related to.",
"items": {
"type": "object",
"properties": {
"id": {
"description": "hex-encoded id of the element that this observation references",
"type": "string"
}
},
"required": ["id"]
}
},
"attachments": {
"type": "array",
"description": "media or other data that are attached to this observation",
Expand Down Expand Up @@ -190,6 +176,6 @@
"additionalProperties": false
}
},
"required": ["schemaName", "tags", "refs", "attachments", "metadata"],
"required": ["schemaName", "tags", "attachments", "metadata"],
"additionalProperties": false
}
1 change: 0 additions & 1 deletion src/lib/decode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const convertObservation: ConvertFunction<'observation'> = (
const obs: Observation = {
...jsonSchemaCommon,
...rest,
refs: message.refs?.map(({ id }) => ({ id: id.toString('hex') })),
attachments: message.attachments.map(convertAttachment),
tags: convertTags(message.tags),
metadata: message.metadata || {},
Expand Down
4 changes: 0 additions & 4 deletions src/lib/encode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ export const convertPreset: ConvertFunction<'preset'> = (mapeoDoc) => {
export const convertObservation: ConvertFunction<'observation'> = (
mapeoDoc
) => {
const refs = mapeoDoc.refs.map((ref) => {
return { id: Buffer.from(ref.id, 'hex') }
})
const attachments = mapeoDoc.attachments.map(convertAttachment)
const metadata: Observation_1_Metadata = mapeoDoc.metadata && {
...Observation_1_Metadata.fromPartial(mapeoDoc.metadata),
Expand All @@ -100,7 +97,6 @@ export const convertObservation: ConvertFunction<'observation'> = (
return {
common: convertCommon(mapeoDoc),
...mapeoDoc,
refs,
attachments,
tags: convertTags(mapeoDoc.tags),
metadata,
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/bad-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const badDocs = [
updatedAt: cachedValues.updatedAt,
createdBy: cachedValues.createdBy,
links: [],
refs: [],
attachments: [],
tags: {},
metadata: {},
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/good-docs-completed.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const goodDocsCompleted = [
links: [],
lat: 24.0424,
lon: 21.0214,
refs: [],
attachments: [
{
name: 'myFile',
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/good-docs-minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const goodDocsMinimal = [
updatedAt: cachedValues.updatedAt,
createdBy: cachedValues.createdBy,
links: [],
refs: [],
attachments: [],
tags: {},
metadata: {},
Expand Down

0 comments on commit 28d8777

Please sign in to comment.