diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f900b6a..3e63a70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Build steps -1. `npm run generate` will generate type definitions and encode/decode functions from `.proto` files, and generate type definitions from json schema files, and place them in `generated`. It will also generate validation functions from json schema files and place that in `dist`. +1. `npm run build:generate` will generate type definitions and encode/decode functions from `.proto` files, and generate type definitions from json schema files, and place them in `generated`. It will also generate validation functions from json schema files and place that in `dist`. 2. `rootDirs` is set in `tsconfig.json` so that files in `src` can import from `generated` as if the two folders were merged 3. `tsc` generates `.js` and `.d.ts` from the files in `src` and `generated` and outputs to `intermediate` 4. A final copy step is needed to merge `intermediate/generated` and `intermediate/src` into `dist`. @@ -13,7 +13,7 @@ Please publish to npm via Github using the release workflow, rather than publish ### 1. Prepare a release -- Navigate to the [release action workflow](https://github.com/digidem/mapeo-schema/actions/workflows/release.yml) and click the "Run workflow" dropdown. +- Navigate to the [release action workflow](https://github.com/digidem/comapeo-schema/actions/workflows/release.yml) and click the "Run workflow" dropdown. - Select the semver release, e.g. "patch" for bug fixes, "minor" for new features, and "major" for breaking changes. For pre-release see below - Click "Run workflow" button. @@ -30,13 +30,13 @@ This will open a new Pull Request with a draft release Prereleases are useful for testing new versions of this package without affecting existing dependent packages. Ideally work on a pre-release should be on a separate branch, e.g. create a `next` branch from `master`. -To prepare the release, select "Run workflow" on the [release action workflow](https://github.com/digidem/mapeo-schema/actions/workflows/release.yml) as above, but select the branch `next` (or whatever branch you are using for prerelease development) for "Use workflow from", and for the "`semver` to use" option, select: +To prepare the release, select "Run workflow" on the [release action workflow](https://github.com/digidem/comapeo-schema/actions/workflows/release.yml) as above, but select the branch `next` (or whatever branch you are using for prerelease development) for "Use workflow from", and for the "`semver` to use" option, select: - `prepatch` to create a new patch prerelease, e.g. if the current version is `v3.0.0`, then this will generate a new release `v3.0.1-next.0`. - `preminor` to create a new minor prerelease, e.g. if the current version is `v3.0.0` then this will generate a new release `v3.1.0-next.0`. - `premajor` to create a new major prerelease, e.g. if the current version is `v3.0.0` then this will generate a new release `v4.0.0-next.0`. - `prelease` to bump the prerelease version if the current version on the branch that you target is already a prerelease and you want to create a new prerelease, e.g. if the current version on the target branch is `v3.0.1-next.0` then this will generate a new release `v3.0.1-next.1`. -The pre-releases will be published to npm with the `next` [dist-tag](https://docs.npmjs.com/adding-dist-tags-to-packages). Publishing a pre-release will not change the `latest` tag, so that normal installs of `npm install @mapeo/schema` will not get the pre-release. To install the pre-release for testing, use `npm install @mapeo/schema@latest`. +The pre-releases will be published to npm with the `next` [dist-tag](https://docs.npmjs.com/adding-dist-tags-to-packages). Publishing a pre-release will not change the `latest` tag, so that normal installs of `npm install @comapeo/schema` will not get the pre-release. To install the pre-release for testing, use `npm install @comapeo/schema@latest`. To publish a `latest` release from a pre-release, first merge the pre-release branch to master, then follow the usual "Prepare a release" steps from above, but select `auto` for the "`semver` to use" option. If you have a prerelease version `v3.0.1-next.3` then this will publish a release called `v3.0.1`. diff --git a/README.md b/README.md index 0703a22..448660b 100644 --- a/README.md +++ b/README.md @@ -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) -[![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,13 +10,12 @@ 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 @@ -28,23 +23,24 @@ npm install --save mapeo-schema ### JS validation functions ```js -const mapeoSchema = require('mapeo-schema') -// also -const validateObservation = require('mapeo-schema/validateObservation') +import { validate } from '@comapeo/schema' -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 - -**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 diff --git a/package.json b/package.json index b072164..6553c9c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "@mapeo/schema", - "version": "3.0.0-next.28", - "description": "JSON schema and flow types for Mapeo", + "name": "@comapeo/schema", + "version": "0.0.0", + "description": "JSON Schema and TypeScript types for CoMapeo", "main": "dist/index.js", "type": "module", "scripts": { @@ -25,18 +25,14 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/digidem/mapeo-schema.git" + "url": "git+https://github.com/digidem/comapeo-schema.git" }, - "keywords": [ - "mapeo", - "schema" - ], - "author": "Digital Democracy", + "author": "Awana Digital", "license": "MIT", "bugs": { - "url": "https://github.com/digidem/mapeo-schema/issues" + "url": "https://github.com/digidem/comapeo-schema/issues" }, - "homepage": "https://github.com/digidem/mapeo-schema#readme", + "homepage": "https://github.com/digidem/comapeo-schema#readme", "devDependencies": { "@bufbuild/buf": "^1.26.1", "@json-schema-tools/dereferencer": "^1.6.3", diff --git a/src/lib/utils.ts b/src/lib/utils.ts index e46d8fe..9add5bb 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -78,11 +78,6 @@ export function parseVersionId(versionId: string): VersionIdObject { return { coreDiscoveryKey, index } } -/** - * @template {import('@mapeo/schema').MapeoDoc & { forks?: string[] }} T - * @param {T} doc - * @returns {Omit} - */ export function valueOf( doc: TDoc & { forks?: string[] } ): FilterBySchemaName {