-
Notifications
You must be signed in to change notification settings - Fork 0
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!: rename to @comapeo/schema
#260
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
# mapeo-schema | ||
# @comapeo/schema | ||
|
||
[![Build Status](https://img.shields.io/travis/digidem/mapeo-schema.svg)](https://travis-ci.org/digidem/mapeo-schema) | ||
[![npm](https://img.shields.io/npm/v/mapeo-schema.svg)](https://www.npmjs.com/package/mapeo-schema) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed these badges. We don't use Travis CI or Standard style, and I didn't feel like updating the npm badge for a version that doesn't (yet) exist. |
||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?maxAge=2592000)](http://standardjs.com/) | ||
|
||
> Document schemas, validators and flow types for Mapeo | ||
JSON Schema and TypeScript types for CoMapeo. | ||
|
||
Original draft: https://hackmd.io/wlMcMM65TmuPXGYOEbOR2g# | ||
|
||
|
@@ -14,37 +10,37 @@ Original draft: https://hackmd.io/wlMcMM65TmuPXGYOEbOR2g# | |
- [Usage](#usage) | ||
- [API](#api) | ||
- [Maintainers](#maintainers) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
## Install | ||
|
||
```sh | ||
npm install --save mapeo-schema | ||
npm install --save @comapeo/schema | ||
``` | ||
|
||
## Usage | ||
|
||
### JS validation functions | ||
|
||
```js | ||
const mapeoSchema = require('mapeo-schema') | ||
// also | ||
const validateObservation = require('mapeo-schema/validateObservation') | ||
import { validate } from '@comapeo/schema' | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated these code examples. |
||
const testObservation = {...} | ||
const testObservation = { | ||
/* ... */ | ||
} | ||
|
||
const isValid = mapeoSchema.validateObservation(testObservation); | ||
const isValid = validate('observation', testObservation) | ||
// returns true if validates against schema, false otherwise. | ||
// errors a static prop on mapeoSchema.validateObservation.errors | ||
``` | ||
|
||
### Flow types | ||
### TypeScript types | ||
|
||
```js | ||
import type { Observation } from 'mapeo-schema' | ||
```typescript | ||
import type { Observation } from '@comapeo/schema' | ||
|
||
const myObs: Observation = {...} | ||
const myObs: Observation = { | ||
/* ... */ | ||
} | ||
``` | ||
|
||
## API | ||
|
@@ -53,34 +49,6 @@ const myObs: Observation = {...} | |
|
||
[@digidem](https://github.com/digidem) | ||
|
||
## Contributing | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this whole section because I think it's outdated. |
||
**It looks like there is no code in this repo**. All the code is generated from | ||
the [JSON Schema definitions](schema/). To build the validator functions and | ||
flow definitions: | ||
|
||
```sh | ||
npm run build | ||
``` | ||
|
||
Tests are also generated dynamically. Place an example minimal and valid JSON | ||
for a particular schema in the [examples](examples/) folder, with a filename | ||
that matches the schema filename, e.g. if you add a schema called | ||
`mySchema.json` then add an example `mySchema.minimal.json` and | ||
`mySchema.full.json`. "Minimal" means with only the required properties, where | ||
"full" means with all the defined properties in the schema document. To run | ||
tests: | ||
|
||
```sh | ||
npm test | ||
``` | ||
|
||
Before publishing, update the docs with: | ||
|
||
```sh | ||
npm run docs | ||
``` | ||
|
||
## License | ||
|
||
MIT © 2019 Digital Democracy | ||
MIT © 2024 Awana Digital |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,11 +78,6 @@ export function parseVersionId(versionId: string): VersionIdObject { | |
return { coreDiscoveryKey, index } | ||
} | ||
|
||
/** | ||
* @template {import('@mapeo/schema').MapeoDoc & { forks?: string[] }} T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This referred to |
||
* @param {T} doc | ||
* @returns {Omit<T, 'docId' | 'versionId' | 'originalVersionId' | 'links' | 'forks' | 'createdAt' | 'updatedAt' | 'deleted'>} | ||
*/ | ||
export function valueOf<TDoc extends MapeoDoc>( | ||
doc: TDoc & { forks?: string[] } | ||
): FilterBySchemaName<MapeoValue, TDoc['schemaName']> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not strictly related, but this was incorrect.