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

feat: Create asset summaries #157

Merged
merged 18 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ddcba71
feat: Require 'linz:asset_summaries' root property
l0b0 Nov 14, 2021
9931751
feat: Require asset summary 'created' propert
l0b0 Nov 14, 2021
ed32691
feat: require asset summary created 'minimum' property
l0b0 Nov 14, 2021
ab4bf48
feat: require asset summary created minimum property be a string
l0b0 Nov 14, 2021
208c890
feat: require asset summary created minimum property be a datetime
l0b0 Nov 14, 2021
96f29c0
feat: require asset summary created minimum property be a UTC datetime
l0b0 Nov 14, 2021
9a5669d
refactor: Pull out UTC datetime definition
l0b0 Nov 14, 2021
084f8dd
docs: Set asset/metadata summary created/updated titles
l0b0 Nov 14, 2021
7d81ff5
feat: require asset summary created 'maximum' property
l0b0 Nov 14, 2021
f401fad
feat: require asset summary created maximum property be a UTC datetime
l0b0 Nov 14, 2021
abc190f
feat: require asset summary 'updated' property
l0b0 Nov 14, 2021
29d00d2
feat: require asset summary updated 'minimum' property
l0b0 Nov 14, 2021
2662008
feat: require asset summary updated minimum property be a UTC datetime
l0b0 Nov 14, 2021
16b2487
feat: require asset summary updated 'maximum' property
l0b0 Nov 14, 2021
97325bc
feat: require asset summary updated maximum property be a UTC datetime
l0b0 Nov 14, 2021
294d409
Merge branch 'master' into feat/create-asset-summaries
l0b0 Nov 23, 2021
1aedd9b
docs: Move asset summary documentation to right property
l0b0 Nov 23, 2021
ac4f385
Merge branch 'master' into feat/create-asset-summaries
l0b0 Nov 24, 2021
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
10 changes: 10 additions & 0 deletions extensions/linz/examples/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
"title": "A title",
"description": "A description",
"license": "Apache-2.0",
"linz:asset_summaries": {
"created": {
"minimum": "1999-01-01T00:00:00Z",
amfage marked this conversation as resolved.
Show resolved Hide resolved
"maximum": "2010-01-01T00:00:00Z"
},
"updated": {
"minimum": "1999-01-01T00:00:00Z",
"maximum": "2010-01-01T00:00:00Z"
}
},
"linz:lifecycle": "under development",
"linz:providers": [
{
Expand Down
69 changes: 47 additions & 22 deletions extensions/linz/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
{
"type": "object",
"required": [
"linz:asset_summaries",
"linz:geospatial_type",
"linz:history",
"linz:lifecycle",
Expand Down Expand Up @@ -131,15 +132,11 @@
"properties": {
"created": {
"title": "Creation time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
"$ref": "#/definitions/utc_datetime"
},
"updated": {
"title": "Last update time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
"$ref": "#/definitions/utc_datetime"
},
"linz:language": {
"title": "IETF RFC 5646 language tag",
Expand Down Expand Up @@ -940,6 +937,37 @@
}
}
},
"linz:asset_summaries": {
"required": ["created", "updated"],
"properties": {
"created": {
"required": ["minimum", "maximum"],
"properties": {
"minimum": {
"title": "Earliest asset creation time",
"$ref": "#/definitions/utc_datetime"
},
"maximum": {
"title": "Latest asset creation time",
"$ref": "#/definitions/utc_datetime"
}
}
},
"updated": {
"required": ["minimum", "maximum"],
"properties": {
"minimum": {
"title": "Earliest asset updated time",
"$ref": "#/definitions/utc_datetime"
},
"maximum": {
"title": "Latest asset updated time",
"$ref": "#/definitions/utc_datetime"
}
}
}
}
},
"linz:geospatial_type": {},
"linz:history": {
"title": "History",
Expand Down Expand Up @@ -1047,16 +1075,12 @@
"required": ["minimum", "maximum"],
"properties": {
"minimum": {
"title": "Earliest asset creation time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
"title": "Earliest metadata creation time",
amfage marked this conversation as resolved.
Show resolved Hide resolved
"$ref": "#/definitions/utc_datetime"
},
"maximum": {
"title": "Latest asset creation time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
"title": "Latest metadata creation time",
"$ref": "#/definitions/utc_datetime"
}
}
},
Expand All @@ -1065,16 +1089,12 @@
"required": ["minimum", "maximum"],
"properties": {
"minimum": {
"title": "Earliest asset updated time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
"title": "Earliest metadata updated time",
"$ref": "#/definitions/utc_datetime"
},
"maximum": {
"title": "Latest asset updated time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
"title": "Latest metadata updated time",
"$ref": "#/definitions/utc_datetime"
}
}
}
Expand All @@ -1089,6 +1109,11 @@
"^(?!linz:)": {}
},
"additionalProperties": false
},
"utc_datetime": {
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
}
}
}
87 changes: 87 additions & 0 deletions extensions/linz/tests/linz_collection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,93 @@ o.spec('LINZ collection', () => {
).equals(true)(JSON.stringify(validate.errors));
});

o("Example without the mandatory 'linz:asset_summaries' property should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['linz:asset_summaries'];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) => error.instancePath === '' && error.message === "must have required property 'linz:asset_summaries'",
),
).equals(true)(JSON.stringify(validate.errors));
});

o("Asset summary without the mandatory 'created'/'updated' properties should fail validation", async () => {
for (const property of ['created', 'updated']) {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['linz:asset_summaries'][property];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) =>
error.instancePath === '/linz:asset_summaries' &&
error.message === `must have required property '${property}'`,
),
).equals(true)(JSON.stringify(validate.errors));
}
});

o(
"Asset summary created/updated without the mandatory 'minimum'/'maximum' properties should fail validation",
async () => {
for (const outerProperty of ['created', 'updated']) {
for (const innerProperty of ['minimum', 'maximum']) {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['linz:asset_summaries'][outerProperty][innerProperty];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) =>
error.instancePath === `/linz:asset_summaries/${outerProperty}` &&
error.message === `must have required property '${innerProperty}'`,
),
).equals(true)(JSON.stringify(validate.errors));
}
}
},
);

o("Asset summary created/updated with invalid 'minimum'/'maximum' value should fail validation", async () => {
for (const outerProperty of ['created', 'updated']) {
for (const innerProperty of ['minimum', 'maximum']) {
// given
const example = JSON.parse(await fs.readFile(examplePath));
example['linz:asset_summaries'][outerProperty][innerProperty] = '1999-01-01T00:00:00';

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) =>
error.instancePath === `/linz:asset_summaries/${outerProperty}/${innerProperty}` &&
error.message === 'must match pattern "(\\+00:00|Z)$"',
),
).equals(true)(JSON.stringify(validate.errors));
}
}
});

o("Example without the mandatory 'linz:history' field should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
Expand Down