generated from zazuko/build-your-vocabularies
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,29 @@ | ||
# @zazuko/build-your-vocabularies | ||
# @hydrofoil/vocabularies | ||
|
||
Roll your own vocabularies package which will export your ontologies/vocabularies as n-quads and code modules. | ||
Collection of vocabularies from the `https://hypermedia.app/` namespace | ||
|
||
## Preparation | ||
## Usage | ||
|
||
Having created a repository from this template, follow the instructions below to create a package with your vocabularies. | ||
### Builders | ||
|
||
1. Adjust `package.json`, at the least by: | ||
* changing the name | ||
* changing the `bin` name | ||
* changing the `indexBase` in `fetch` script | ||
* possibly remove `private: true` | ||
2. Prepare your vocabularies: | ||
* add their prefix/namespace pairs in [src/prefixes.ts](src/prefixes.ts) | ||
* if necessary, set up their fetch routine in [`build/overrides.ts`](build/overrides.ts) | ||
* see [here](https://github.com/zazuko/rdf-vocabularies/blob/master/overrides.ts) for examples of various overrides | ||
* local vocabularies can be created in [src/vocabulary](src/vocabulary) as RDF sources | ||
3. `npm run fetch` | ||
* optionally call as `npm run fetch -- <prefix>` to fetch+process only one | ||
4. Customise this readme | ||
4. Commit the result | ||
5. Bump version and publish your package | ||
* Might consider setting CI automation | ||
Easily construct terms using exported namespace builders | ||
|
||
Check the `example` branch for inspiration | ||
```typescript | ||
import { knossos } from '@hydrofoil/vocabularies/builders' | ||
|
||
## Usage | ||
const { memberTemplate } = knossos | ||
``` | ||
|
||
The final product will be an extension to the `@zazuko/rdf-vocabularies`, albeit with side effects. Simply import in your project the to have you prefixes added to the default selection. | ||
### Extend `@zazuko/rdf-vocabularies` | ||
|
||
Import somewhere at the beginning of your code | ||
|
||
```javascript | ||
// replace with your package name | ||
import '@zazuko/build-your-vocabularies' | ||
import '@hydrofoil/vocabularies' | ||
``` | ||
|
||
Additionally, modules exporting `@rdfjs/namespace` builders will be generated. | ||
The namespaces will be added to the default selection and thus apply to the `expand/shrink` functionality as well as external libraries such as `@tpluscode/rdf-string`. | ||
|
||
```javascript | ||
// default builders | ||
import { prefixA } from '@zazuko/build-your-vocabularies/builders' | ||
|
||
// strict builders prevent constructing terms which are not defined in vocabulary | ||
import { prefixB } from '@zazuko/build-your-vocabularies/builders/strict' | ||
import { prefixes } from '@zazuko/rdf-vocabularies' | ||
``` | ||
|
||
Check [`@zazuko/rdf-vocabularies` readme](https://github.com/zazuko/rdf-vocabularies#usage) for detailed usage instructions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
export default { | ||
const prefixes = { | ||
'hyper-auth': 'https://hypermedia.app/auth#', | ||
'hyper-events': 'https://hypermedia.app/events#', | ||
'hyper-query': 'https://hypermedia.app/query#', | ||
knossos: 'https://hypermedia.app/knossos#', | ||
roadshow: 'https://hypermedia.app/roadshow#' | ||
} | ||
|
||
type LocalPrefixes = typeof prefixes | ||
|
||
declare module '@zazuko/rdf-vocabularies/prefixes' { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface Prefixes extends LocalPrefixes { | ||
} | ||
} | ||
|
||
export default prefixes |