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: move type out of docRef and call it docRefType #208

Merged
merged 2 commits into from
Aug 5, 2024
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
12 changes: 11 additions & 1 deletion proto/translation/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ message Translation_1 {
message DocRef {
bytes docId = 1;
VersionId_1 versionId = 2;
string type = 3;
}
enum DocRefType {
type_unspecified = 0;
deviceInfo = 1;
preset = 2;
field = 3;
observation = 4;
projectSettings = 5;
role = 6;
track = 7;
}
DocRefType docRefType = 7;

}
22 changes: 17 additions & 5 deletions schema/translation/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,24 @@
"versionId": {
"description": "core discovery id (hex-encoded 32-byte buffer) and core index number, separated by '/'",
"type": "string"
},
"type": {
"description": "type of the element that this translation references",
"type": "string"
}
},
"required": ["docId", "versionId", "type"]
"required": ["docId", "versionId"]
},
"docRefType": {
"description": "type of the element that this translation references",
"type": "string",
"enum": [
"type_unspecified",
"deviceInfo",
"preset",
"field",
"observation",
"projectSettings",
"role",
"track",
"UNRECOGNIZED"
]
},
"propertyRef": {
"type": "string",
Expand All @@ -47,6 +58,7 @@
"required": [
"schemaName",
"docRef",
"docRefType",
"propertyRef",
"languageCode",
"regionCode",
Expand Down
1 change: 0 additions & 1 deletion src/lib/decode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ export const convertTranslation: ConvertFunction<'translation'> = (
docRef: {
docId: message.docRef.docId.toString('hex'),
versionId: getVersionId(message.docRef.versionId),
type: message.docRef.type,
},
}
}
Expand Down
1 change: 0 additions & 1 deletion src/lib/encode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ export const convertTranslation: ConvertFunction<'translation'> = (
docRef: {
docId: Buffer.from(mapeoDoc.docRef.docId, 'hex'),
versionId: parseVersionId(mapeoDoc.docRef.versionId),
type: mapeoDoc.docRef.type,
},
}
}
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 @@ -269,8 +269,8 @@ export const goodDocsCompleted = [
docRef: {
docId: cachedValues.refs.docId,
versionId: cachedValues.refs.versionId,
type: 'preset',
},
docRefType: 'preset',
propertyRef: 'terms[0]',
languageCode: 'es',
regionCode: 'AR',
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/good-docs-minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ export const goodDocsMinimal = [
docRef: {
docId: cachedValues.refs.docId,
versionId: cachedValues.refs.versionId,
type: 'field',
},
docRefType: 'field',
propertyRef: 'label',
languageCode: 'qu',
regionCode: 'PE',
Expand Down
Loading