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!: improve decoding of required fields #254

Merged
merged 34 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9f9c344
fix!: remove `isInitialProject` from project settings
EvanHahn Sep 10, 2024
2649d78
chore!: improve decoding of required fields
EvanHahn Sep 10, 2024
4cbaf8f
Tweak which proto fields are optional
EvanHahn Sep 11, 2024
931f473
Always specify `DeviceInfo.deviceType`
EvanHahn Sep 11, 2024
0bd5ab4
Give required strings a minLength
EvanHahn Sep 11, 2024
2bd2735
Move ajv to production dependencies
EvanHahn Sep 11, 2024
03ae64a
Make regionCode optional, because it is optional in default config
EvanHahn Sep 11, 2024
76563d9
Allow empty translation messages, which could legitimately happen
EvanHahn Sep 12, 2024
fefbb9a
Merge branch 'main' into optionalify
EvanHahn Sep 12, 2024
e8e7e53
Merge branch 'main' into optionalify
EvanHahn Sep 12, 2024
1bfedae
Don't require DeviceInfo to have a name
EvanHahn Sep 12, 2024
c922df4
Preset should allow empty name field
EvanHahn Sep 12, 2024
b66076d
Revert a change
EvanHahn Sep 12, 2024
3beea87
Require DeviceInfo to have deviceType
EvanHahn Sep 12, 2024
a3b10ce
getVersionId should ensure valid inputs
EvanHahn Sep 12, 2024
9ea53a1
Document `ensure`
EvanHahn Sep 12, 2024
e585e2d
Make preset.color optional
EvanHahn Sep 12, 2024
4403044
Merge branch 'main' into optionalify
EvanHahn Sep 12, 2024
0850932
Merge branch 'main' into optionalify
EvanHahn Sep 16, 2024
4db2f17
Icon name isn't as required
EvanHahn Sep 16, 2024
d5c0981
Translation messages can be empty
EvanHahn Sep 16, 2024
d4e4eaa
Handle required fields in observation attachments
EvanHahn Sep 16, 2024
f042b7a
Project settings config metadata cleanup
EvanHahn Sep 16, 2024
5faaba6
Field type requirement cleanup
EvanHahn Sep 16, 2024
9196cfa
Presets: name and color requirements on decode
EvanHahn Sep 16, 2024
afaec2b
Improve decoding device info
EvanHahn Sep 16, 2024
90659dd
Remove unnecessary destructuring in convertIcon
EvanHahn Sep 16, 2024
2ecd8a8
Don't require translation message on decode
EvanHahn Sep 16, 2024
5b5d618
Be lenient with observation refs on convertTrackPosition
EvanHahn Sep 16, 2024
b1f34cf
Remove double ensure function
EvanHahn Sep 16, 2024
2f3f4b9
Handle errors from convertIconVariant
EvanHahn Sep 16, 2024
0c0eb70
Don't check icon sizes (allow unspecified)
EvanHahn Sep 16, 2024
fd090d6
convertAttachment should throw for consistency
EvanHahn Sep 16, 2024
44f7a5f
Remove unnecessary name/deviceType
EvanHahn Sep 16, 2024
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
13 changes: 4 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"@json-schema-tools/dereferencer": "^1.6.3",
"@types/compact-encoding": "^2.15.0",
"@types/json-schema": "^7.0.12",
"ajv": "^8.12.0",
"c8": "^8.0.1",
"cpy-cli": "^5.0.0",
"eslint": "^8.46.0",
Expand All @@ -61,6 +60,7 @@
"typescript": "^5.5.4"
},
"dependencies": {
"ajv": "^8.12.0",
"compact-encoding": "^2.12.0",
"protobufjs": "^7.2.5",
"type-fest": "^4.26.0"
Expand Down
12 changes: 6 additions & 6 deletions proto/coreOwnership/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ message CoreOwnership_1 {

Common_1 common = 1;

bytes authCoreId = 5;
bytes configCoreId = 6;
bytes dataCoreId = 7;
bytes blobCoreId = 8;
bytes blobIndexCoreId = 9;
CoreSignatures coreSignatures = 10;
bytes authCoreId = 5 [(required) = true];
bytes configCoreId = 6 [(required) = true];
bytes dataCoreId = 7 [(required) = true];
bytes blobCoreId = 8 [(required) = true];
bytes blobIndexCoreId = 9 [(required) = true];
CoreSignatures coreSignatures = 10 [(required) = true];
bytes identitySignature = 11;

message CoreSignatures {
Expand Down
4 changes: 2 additions & 2 deletions proto/deviceInfo/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ message DeviceInfo_1 {
selfHostedServer = 4;
}

string name = 5;
optional DeviceType deviceType = 6;
string name = 5 [(required) = true];
EvanHahn marked this conversation as resolved.
Show resolved Hide resolved
DeviceType deviceType = 6;
}
4 changes: 2 additions & 2 deletions proto/preset/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ message Preset_1 {

Common_1 common = 1;

string name = 5;
string name = 5 [(required) = true];
EvanHahn marked this conversation as resolved.
Show resolved Hide resolved
repeated Geometry geometry = 6;
map<string, TagValue_1> tags = 7;
map<string, TagValue_1> addTags = 8;
map<string, TagValue_1> removeTags = 9;
repeated FieldRef fieldRefs = 10;
optional IconRef iconRef = 11;
repeated string terms = 12;
string color = 13;
string color = 13 [(required) = true];
EvanHahn marked this conversation as resolved.
Show resolved Hide resolved

enum Geometry {
geometry_unspecified = 0;
Expand Down
4 changes: 2 additions & 2 deletions proto/role/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ message Role_1 {

Common_1 common = 1;

bytes roleId = 5;
uint32 fromIndex = 6;
bytes roleId = 5 [(required) = true];
optional uint32 fromIndex = 6 [(required) = true];
}
8 changes: 4 additions & 4 deletions proto/translation/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ message Translation_1 {
Common_1 common = 1;
DocRef docRef = 2;

string propertyRef = 3;
string languageCode = 4;
string regionCode = 5;
string message = 6;
string propertyRef = 3 [(required) = true];
string languageCode = 4 [(required) = true];
optional string regionCode = 5;
string message = 6 [(required) = true];

message DocRef {
bytes docId = 1;
Expand Down
12 changes: 8 additions & 4 deletions schema/common/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
"properties": {
"docId": {
"description": "Hex-encoded 32-byte buffer",
"type": "string"
"type": "string",
"minLength": 1
},
"versionId": {
"description": "core discovery id (hex-encoded 32-byte buffer) and core index number, separated by '/'",
"type": "string"
"type": "string",
"minLength": 1
},
"originalVersionId": {
"description": "Version ID of the original version of this document. For the original version, matches `versionId`.",
"type": "string"
"type": "string",
"minLength": 1
},
"schemaName": {
"description": "Name of Mapeo data type / schema",
"type": "string"
"type": "string",
"minLength": 1
},
"createdAt": {
"description": "RFC3339-formatted datetime of when the first version of the element was created",
Expand Down
15 changes: 10 additions & 5 deletions schema/coreOwnership/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,28 @@
},
"authCoreId": {
"type": "string",
"description": "Hex-encoded key of auth store writer core"
"description": "Hex-encoded key of auth store writer core",
"minLength": 1
},
"configCoreId": {
"type": "string",
"description": "Hex-encoded key of config store writer core"
"description": "Hex-encoded key of config store writer core",
"minLength": 1
},
"dataCoreId": {
"type": "string",
"description": "Hex-encoded key of data store writer core"
"description": "Hex-encoded key of data store writer core",
"minLength": 1
},
"blobCoreId": {
"type": "string",
"description": "Hex-encoded key of blob store writer core"
"description": "Hex-encoded key of blob store writer core",
"minLength": 1
},
"blobIndexCoreId": {
"type": "string",
"description": "Hex-encoded key of blobIndex store writer core"
"description": "Hex-encoded key of blobIndex store writer core",
"minLength": 1
}
},
"required": [
Expand Down
3 changes: 2 additions & 1 deletion schema/deviceInfo/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"name": {
"type": "string",
"description": "Name of the device"
"description": "Name of the device",
"minLength": 1
},
"deviceType": {
EvanHahn marked this conversation as resolved.
Show resolved Hide resolved
"type": "string",
Expand Down
9 changes: 6 additions & 3 deletions schema/field/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"tagKey": {
"description": "They key in a tags object that this field applies to",
"type": "string"
"type": "string",
"minLength": 1
},
"type": {
"description": "Type of field - defines how the field is displayed to the user.",
Expand All @@ -35,7 +36,8 @@
},
"label": {
"description": "Default language label for the form field label",
"type": "string"
"type": "string",
"minLength": 1
},
"appearance": {
"description": "For text fields, display as a single-line or multi-line field",
Expand Down Expand Up @@ -66,7 +68,8 @@
"type": "object",
"properties": {
"label": {
"type": "string"
"type": "string",
"minLength": 1
},
"value": {
"anyOf": [
Expand Down
6 changes: 4 additions & 2 deletions schema/icon/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"blobVersionId": {
"description": "Version id of the icon blob. Each id is id (hex-encoded 32 byte buffer) and index number, separated by '/'",
"type": "string"
"type": "string",
"minLength": 1
}
},
"properties": {
Expand All @@ -21,7 +22,8 @@
"const": "icon"
},
"name": {
"type": "string"
"type": "string",
"minLength": 1
},
"variants": {
"type": "array",
Expand Down
15 changes: 10 additions & 5 deletions schema/observation/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@
"properties": {
"driveDiscoveryId": {
"type": "string",
"description": "core discovery id for the drive that the attachment belongs to"
"description": "core discovery id for the drive that the attachment belongs to",
"minLength": 1
},
"name": {
"type": "string",
"description": "name of the attachment"
"description": "name of the attachment",
"minLength": 1
},
"type": {
"type": "string",
Expand All @@ -99,7 +101,8 @@
},
"hash": {
"type": "string",
"description": "SHA256 hash of the attachment"
"description": "SHA256 hash of the attachment",
"minLength": 1
}
},
"required": ["driveDiscoveryId", "name", "type", "hash"]
Expand Down Expand Up @@ -192,11 +195,13 @@
"properties": {
"docId": {
"description": "hex-encoded id of the element that this observation references",
"type": "string"
"type": "string",
"minLength": 1
},
"versionId": {
"description": "core discovery id (hex-encoded 32-byte buffer) and core index number, separated by '/'",
"type": "string"
"type": "string",
"minLength": 1
}
},
"required": ["docId", "versionId"]
Expand Down
15 changes: 10 additions & 5 deletions schema/preset/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
},
"name": {
"description": "Name for the feature in default language.",
"type": "string"
"type": "string",
"minLength": 1
},
"geometry": {
"description": "Valid geometry types for the feature - this preset will only match features of this geometry type `\"point\", \"vertex\", \"line\", \"area\", \"relation\"`",
Expand Down Expand Up @@ -84,11 +85,13 @@
"properties": {
"docId": {
"description": "hex-encoded id of the element that this observation references",
"type": "string"
"type": "string",
"minLength": 1
},
"versionId": {
"description": "core discovery id (hex-encoded 32-byte buffer) and core index number, separated by '/'",
"type": "string"
"type": "string",
"minLength": 1
}
},
"required": ["docId", "versionId"]
Expand All @@ -100,11 +103,13 @@
"properties": {
"docId": {
"description": "hex-encoded id of the element that this observation references",
"type": "string"
"type": "string",
"minLength": 1
},
"versionId": {
"description": "core discovery id (hex-encoded 32-byte buffer) and core index number, separated by '/'",
"type": "string"
"type": "string",
"minLength": 1
}
},
"required": ["docId", "versionId"]
Expand Down
6 changes: 4 additions & 2 deletions schema/projectSettings/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"properties": {
"name": {
"type": "string",
"description": "Name of the configuration"
"description": "Name of the configuration",
"minLength": 1
},
"buildDate": {
"type": "string",
Expand All @@ -44,7 +45,8 @@
},
"fileVersion": {
"type": "string",
"description": "version of the configuration file format as comver (MAJOR.MINOR)"
"description": "version of the configuration file format as comver (MAJOR.MINOR)",
"minLength": 1
}
},
"additionalProperties": false,
Expand Down
3 changes: 2 additions & 1 deletion schema/role/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"roleId": {
"type": "string",
"description": "Unique identifier for role assigned to device with auth core ID equal to `docId` of this record"
"description": "Unique identifier for role assigned to device with auth core ID equal to `docId` of this record",
"minLength": 1
},
"fromIndex": {
"type": "integer",
Expand Down
Loading
Loading