Skip to content

Commit

Permalink
feat: add geekout schema and tests (#2)
Browse files Browse the repository at this point in the history
* feat: add geekout schema and tests

* fix: git ignore

* fix: schema json

* fix: readme typos

* fix: schema fix

* fix: pr edits for date type

* fix: include lodash dev-dep

Co-authored-by: Matthea Loo <[email protected]>
  • Loading branch information
dhemutton and dhemutton authored Oct 19, 2020
1 parent 389ceb1 commit 4a6b79f
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
/src/__generated__
/node_modules
/dist
/coverage
/coverage
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
1. Make sure the `$id` of your schema is the URL from which the schema will be available at.
1. Add tests for your schema.
1. Generate Typescript types:
- Update `scripts/post-install.js` and call the `generate` function y providing the following named arguments:
- Update `scripts/post-install.js` and call the `generate` function by providing the following named arguments:
- `path` to indicate where your schema is located. Do not provide the `src` folder.
- `rootTypeName` to specify the name of the default exported object.
- Run `npm postinstall` to generate the types.
- Run `npm run postinstall` to generate the types.
- Update `src/index.ts` to export the generated types. In order to prevent name collision, use the `import *` notation to import all the types related to your new schema under a specific name. Then re-export that name.

> Feel free to refer to previously created schemata for help.
66 changes: 63 additions & 3 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@commitlint/prompt": "8.3.3",
"@ls-age/commitlint-circle": "1.0.0",
"@types/jest": "^24.0.23",
"@types/lodash": "^4.14.162",
"@typescript-eslint/eslint-plugin": "^2.8.0",
"@typescript-eslint/parser": "^2.8.0",
"commitizen": "4.0.3",
Expand All @@ -32,6 +33,7 @@
"eslint-plugin-prettier": "^3.1.1",
"git-cz": "^3.3.0",
"jest": "^24.9.0",
"lodash": "^4.17.20",
"mkdirp": "^1.0.4",
"prettier": "^1.19.1",
"quicktype": "^15.0.207",
Expand Down
16 changes: 16 additions & 0 deletions src/sg/gov/tech/geekout/1.0/sample-document.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"recipient": {
"name": "Matthea Loo"
},
"programme": {
"name": "GeekOut 2020",
"startDate": "2020-10-12",
"endDate": "2020-10-14"
},
"signatory": {
"name": "Alice",
"position": "Boss",
"organisation": "ABC",
"signature": "signature"
}
}
108 changes: 38 additions & 70 deletions src/sg/gov/tech/geekout/1.0/schema.json
Original file line number Diff line number Diff line change
@@ -1,99 +1,67 @@
{
"$id": "opencerts/v1.0",
"$id": "https://schemata.openattestation.com/sg/gov/tech/geekout/1.0",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"issuedOn": {
"type": "string"
},
"expiredOn": {
"type": "string"
},
"name": {
"type": "string"
},
"issuer": {
"signatory": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"did": {
"position": {
"type": "string"
},
"url": {
"organisation": {
"type": "string"
},
"email": {
"type": "string"
},
"phone": {
"type": "string"
},
"certificateStore": {
"signature": {
"type": "string"
}
},
"required": ["name", "certificateStore"],
"additionalProperties": false
"required": [
"name",
"position",
"organisation",
"signature"
]
},
"recipient": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"did": {
"type": "string"
},
"url": {
}
},
"required": [
"name"
]
},
"programme": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
"startDate": {
"type": "string",
"format": "date"
},
"phone": {
"type": "string"
"endDate": {
"type": "string",
"format": "date"
}
},
"required": ["name"],
"additionalProperties": false
},
"transcript": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"score": {
"type": ["number", "string"]
},
"grade": {
"type": ["number", "string"]
},
"courseCredit": {
"type": ["number", "string"]
},
"courseCode": {
"type": "string"
},
"url": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": ["name"],
"additionalProperties": false
}
},
"metadata": {
"type": "object"
"required": [
"name",
"startDate",
"endDate"
]
}
},
"required": ["name", "issuedOn", "issuer", "recipient"],
"additionalProperties": false
}
"required": [
"signatory",
"programme",
"recipient"
]
}
Loading

0 comments on commit 4a6b79f

Please sign in to comment.