diff --git a/.github/remark.yaml b/.github/remark.yaml new file mode 100644 index 0000000..70dddb2 --- /dev/null +++ b/.github/remark.yaml @@ -0,0 +1,46 @@ +plugins: +# GitHub Flavored Markdown + - remark-gfm +# Check links + - validate-links +# Apply some recommended defaults for consistency + - remark-preset-lint-consistent + - remark-preset-lint-recommended + - lint-no-html +# General formatting + - - remark-lint-emphasis-marker + - '*' + - remark-lint-no-undefined-references + - remark-lint-hard-break-spaces + - remark-lint-blockquote-indentation + - remark-lint-no-consecutive-blank-lines + - - remark-lint-maximum-line-length + - 150 +# Code + - remark-lint-fenced-code-flag + - remark-lint-fenced-code-marker + - remark-lint-no-shell-dollars + - - remark-lint-code-block-style + - 'fenced' +# Headings + - remark-lint-heading-increment + - remark-lint-no-multiple-toplevel-headings + - remark-lint-no-heading-punctuation + - - remark-lint-maximum-heading-length + - 70 + - - remark-lint-heading-style + - atx + - - remark-lint-no-shortcut-reference-link + - false +# Lists + - remark-lint-list-item-bullet-indent + - remark-lint-ordered-list-marker-style + - remark-lint-ordered-list-marker-value + - remark-lint-checkbox-character-style + - - remark-lint-unordered-list-marker-style + - '-' + - - remark-lint-list-item-indent + - space +# Tables + - remark-lint-table-pipes + - remark-lint-no-literal-urls diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..029974a --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,17 @@ +name: Publish JSON Schema +on: + release: + types: [published] +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Inject env variables + uses: rlespinasse/github-slug-action@v4.4.1 + - uses: actions/checkout@v4 + - name: deploy JSON Schema for version ${{ env.GITHUB_REF_SLUG }} + uses: peaceiris/actions-gh-pages@v3.9.3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: json-schema + destination_dir: ${{ env.GITHUB_REF_SLUG }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..0b7a055 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,13 @@ +name: Check Markdown and Examples +on: [push, pull_request] +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + - uses: actions/checkout@v4 + - run: | + npm install + npm test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ab09c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# OS files +.DS_Store +Thumbs.db + +# Editors +/.idea/ +/.vscode/ + +# Node / npm +.npm +/node_modules/ +package-lock.json \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..dd0fd2f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +[Unreleased]: diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf65d0e --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +# Template Extension Specification + +- **Title:** Template +- **Identifier:** +- **Field Name Prefix:** template +- **Scope:** Item, Collection +- **Extension [Maturity Classification](https://github.com/radiantearth/stac-spec/tree/master/extensions/README.md#extension-maturity):** Proposal +- **Owner**: @your-gh-handles @person2 + +This document explains the Template Extension to the [SpatioTemporal Asset Catalog](https://github.com/radiantearth/stac-spec) (STAC) specification. +This is the place to add a short introduction. + +- Examples: + - [Item example](examples/item.json): Shows the basic usage of the extension in a STAC Item + - [Collection example](examples/collection.json): Shows the basic usage of the extension in a STAC Collection +- [JSON Schema](json-schema/schema.json) +- [Changelog](./CHANGELOG.md) + +## Fields + +The fields in the table below can be used in these parts of STAC documents: + +- [ ] Catalogs +- [x] Collections +- [x] Item Properties (incl. Summaries in Collections) +- [x] Assets (for both Collections and Items, incl. Item Asset Definitions in Collections) +- [ ] Links + +| Field Name | Type | Description | +| -------------------- | ------------------------- | -------------------------------------------- | +| template:new_field | string | **REQUIRED**. Describe the required field... | +| template:xyz | [XYZ Object](#xyz-object) | Describe the field... | +| template:another_one | \[number] | Describe the field... | + +### Additional Field Information + +#### template:new_field + +This is a much more detailed description of the field `template:new_field`... + +### XYZ Object + +This is the introduction for the purpose and the content of the XYZ Object... + +| Field Name | Type | Description | +| ---------- | ------ | -------------------------------------------- | +| x | number | **REQUIRED**. Describe the required field... | +| y | number | **REQUIRED**. Describe the required field... | +| z | number | **REQUIRED**. Describe the required field... | + +## Relation types + +The following types should be used as applicable `rel` types in the +[Link Object](https://github.com/radiantearth/stac-spec/tree/master/item-spec/item-spec.md#link-object). + +| Type | Description | +| -------------- | ------------------------------------- | +| fancy-rel-type | This link points to a fancy resource. | + +## Contributing + +All contributions are subject to the +[STAC Specification Code of Conduct](https://github.com/radiantearth/stac-spec/blob/master/CODE_OF_CONDUCT.md). +For contributions, please follow the +[STAC specification contributing guide](https://github.com/radiantearth/stac-spec/blob/master/CONTRIBUTING.md) Instructions +for running tests are copied here for convenience. + +### Running tests + +The same checks that run as checks on PR's are part of the repository and can be run locally to verify that changes are valid. +To run tests locally, you'll need `npm`, which is a standard part of any [node.js installation](https://nodejs.org/en/download/). + +First you'll need to install everything with npm once. Just navigate to the root of this repository and on +your command line run: +```bash +npm install +``` + +Then to check markdown formatting and test the examples against the JSON schema, you can run: +```bash +npm test +``` + +This will spit out the same texts that you see online, and you can then go and fix your markdown or examples. + +If the tests reveal formatting problems with the examples, you can fix them with: +```bash +npm run format-examples +``` diff --git a/examples/collection.json b/examples/collection.json new file mode 100644 index 0000000..2472ecc --- /dev/null +++ b/examples/collection.json @@ -0,0 +1,73 @@ +{ + "stac_version": "1.0.0", + "stac_extensions": [ + "https://stac-extensions.github.io/item-assets/v1.0.0/schema.json", + "https://stac-extensions.github.io/template/v1.0.0/schema.json" + ], + "type": "Collection", + "id": "collection", + "title": "A title", + "description": "A description", + "license": "Apache-2.0", + "extent": { + "spatial": { + "bbox": [ + [ + 172.9, + 1.3, + 173, + 1.4 + ] + ] + }, + "temporal": { + "interval": [ + [ + "2015-06-23T00:00:00Z", + null + ] + ] + } + }, + "template:new_field": "test", + "template:xyz": { + "x": 1, + "y": 2, + "z": 3 + }, + "template:another_one": [ + 1, + 2, + 3 + ], + "assets": { + "example": { + "href": "https://example.com/examples/file.xyz", + "template:new_field": "test" + } + }, + "item_assets": { + "data": { + "roles": [ + "data" + ], + "template:new_field": "test" + } + }, + "summaries": { + "datetime": { + "minimum": "2015-06-23T00:00:00Z", + "maximum": "2019-07-10T13:44:56Z" + } + }, + "links": [ + { + "href": "https://example.com/examples/collection.json", + "rel": "self" + }, + { + "href": "https://example.com/examples/item.json", + "rel": "item" + } + ] +} diff --git a/examples/item.json b/examples/item.json new file mode 100644 index 0000000..cf19370 --- /dev/null +++ b/examples/item.json @@ -0,0 +1,67 @@ +{ + "stac_version": "1.0.0", + "stac_extensions": [ + "https://stac-extensions.github.io/template/v1.0.0/schema.json" + ], + "type": "Feature", + "id": "item", + "bbox": [ + 172.9, + 1.3, + 173, + 1.4 + ], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 172.9, + 1.3 + ], + [ + 173, + 1.3 + ], + [ + 173, + 1.4 + ], + [ + 172.9, + 1.4 + ], + [ + 172.9, + 1.3 + ] + ] + ] + }, + "properties": { + "datetime": "2020-12-11T22:38:32Z", + "template:new_field": "test", + "template:xyz": { + "x": 1, + "y": 2, + "z": 3 + }, + "template:another_one": [ + 1, + 2, + 3 + ] + }, + "links": [ + { + "href": "https://example.com/examples/item.json", + "rel": "self" + } + ], + "assets": { + "data": { + "href": "https://example.com/examples/file.xyz", + "template:new_field": "test" + } + } +} diff --git a/json-schema/schema.json b/json-schema/schema.json new file mode 100644 index 0000000..8eae23b --- /dev/null +++ b/json-schema/schema.json @@ -0,0 +1,209 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://stac-extensions.github.io/template/v1.0.0/schema.json#", + "title": "Template Extension", + "description": "STAC Template Extension for STAC Items and STAC Collections.", + "oneOf": [ + { + "$comment": "This is the schema for STAC Items. Remove this object if this extension only applies to Collections.", + "allOf": [ + { + "$ref": "#/definitions/stac_extensions" + }, + { + "type": "object", + "required": [ + "type", + "properties", + "assets" + ], + "properties": { + "type": { + "const": "Feature" + }, + "properties": { + "allOf": [ + { + "$comment": "Require fields here for Item Properties.", + "required": [ + "template:new_field" + ] + }, + { + "$ref": "#/definitions/fields" + } + ] + }, + "assets": { + "$comment": "This validates the fields in Item Assets, but does not require them.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/fields" + } + } + } + } + ] + }, + { + "$comment": "This is the schema for STAC Collections.", + "type": "object", + "allOf": [ + { + "required": [ + "type" + ], + "properties": { + "type": { + "const": "Collection" + } + } + }, + { + "$ref": "#/definitions/stac_extensions" + } + ], + "anyOf": [ + { + "$comment": "This is the schema for the top-level fields in a Collection. Remove this if this extension does not define top-level fields for Collections.", + "allOf": [ + { + "$comment": "Require fields here for Collections (top-level).", + "required": [ + "template:new_field" + ] + }, + { + "$ref": "#/definitions/fields" + } + ] + }, + { + "$comment": "This validates the fields in Collection Assets, but does not require them.", + "required": [ + "assets" + ], + "properties": { + "assets": { + "type": "object", + "not": { + "additionalProperties": { + "not": { + "allOf": [ + { + "$ref": "#/definitions/require_any_field" + }, + { + "$ref": "#/definitions/fields" + } + ] + } + } + } + } + } + }, + { + "$comment": "This is the schema for the fields in Item Asset Definitions. It doesn't require any fields.", + "required": [ + "item_assets" + ], + "properties": { + "item_assets": { + "type": "object", + "not": { + "additionalProperties": { + "not": { + "allOf": [ + { + "$ref": "#/definitions/require_any_field" + }, + { + "$ref": "#/definitions/fields" + } + ] + } + } + } + } + } + }, + { + "$comment": "This is the schema for the fields in Summaries. By default, only checks the existence of the properties, but not the schema of the summaries.", + "required": [ + "summaries" + ], + "properties": { + "summaries": { + "$ref": "#/definitions/require_any_field" + } + } + } + ] + } + ], + "definitions": { + "stac_extensions": { + "type": "object", + "required": [ + "stac_extensions" + ], + "properties": { + "stac_extensions": { + "type": "array", + "contains": { + "const": "https://stac-extensions.github.io/template/v1.0.0/schema.json" + } + } + } + }, + "require_any_field": { + "$comment": "Please list all fields here so that we can force the existence of one of them in other parts of the schemas.", + "anyOf": [ + {"required": ["template:new_field"]}, + {"required": ["template:xyz"]}, + {"required": ["template:another_one"]} + ] + }, + "fields": { + "$comment": "Add your new fields here. Don't require them here, do that above in the corresponding schema.", + "type": "object", + "properties": { + "template:new_field": { + "type": "string" + }, + "template:xyz": { + "type": "object", + "required": [ + "x", + "y", + "z" + ], + "properties": { + "x": { + "type": "number" + }, + "y": { + "type": "number" + }, + "z": { + "type": "number" + } + } + }, + "template:another_one": { + "type": "array", + "items": { + "type": "number" + } + } + }, + "patternProperties": { + "^(?!template:)": { + "$comment": "Above, change `template` to the prefix of this extension" + } + }, + "additionalProperties": false + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..c8eee26 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "stac-extension-template", + "version": "1.0.0", + "scripts": { + "test": "npm run check-markdown && npm run check-examples", + "check-markdown": "remark . -f -r .github/remark.yaml", + "check-examples": "stac-node-validator . --lint --verbose --schemaMap https://stac-extensions.github.io/template/v1.0.0/schema.json=./json-schema/schema.json", + "format-examples": "stac-node-validator . --format --schemaMap https://stac-extensions.github.io/template/v1.0.0/schema.json=./json-schema/schema.json" + }, + "dependencies": { + "remark-cli": "^12.0.0", + "remark-gfm": "^4.0.0", + "remark-lint": "^9.1.2", + "remark-lint-no-html": "^3.1.2", + "remark-preset-lint-consistent": "^5.1.2", + "remark-preset-lint-markdown-style-guide": "^5.1.3", + "remark-preset-lint-recommended": "^6.1.3", + "remark-validate-links": "^13.0.0", + "stac-node-validator": "^1.3.0" + } +}