Skip to content

Commit

Permalink
chore: generate remoteDetectionAlert schema, chore: update @comapeo/s…
Browse files Browse the repository at this point in the history
…chema to v1.1.1 (#21)

* update mapeo/schema

* try to ref `Geometry`

* inline `Geometry` schema in `RemoteDetectionAlert`

* reverted accidental version bump

* update comapeo/schema to 1.1.1

* Fix ts-ignore

---------

Co-authored-by: Tomás Ciccola <[email protected]>
Co-authored-by: Evan Hahn <[email protected]>
  • Loading branch information
3 people authored Oct 9, 2024
1 parent 3601918 commit 07c678f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 14 deletions.
14 changes: 14 additions & 0 deletions lib/faker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { JSONSchemaFaker } from 'json-schema-faker'
import { faker } from '@faker-js/faker'
import deref from 'dereference-json-schema'
import { readFile } from 'node:fs/promises'

const geometryPath = new URL(
'../node_modules/@comapeo/geometry/json/geometry.json',
import.meta.url,
).pathname
const Geometry = JSON.parse(await readFile(geometryPath, 'utf-8'))

/**
* @typedef {typeof import('@comapeo/schema').docSchemas[import('@comapeo/schema/dist/types.js').SchemaName]} ValidSchema
Expand Down Expand Up @@ -167,6 +175,12 @@ function createFakerSchema(schema) {

return s
}
case 'RemoteDetectionAlert':
s.properties.geometry = {
$ref: Geometry.$id,
...deref.dereferenceSync(Geometry),
}
return s
}
}

Expand Down
57 changes: 44 additions & 13 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"dependencies": {
"@faker-js/faker": "^8.3.1",
"dereference-json-schema": "^0.2.1",
"json-schema-faker": "^0.5.3",
"type-fest": "^4.8.0"
},
Expand All @@ -41,7 +42,7 @@
"typescript": "^5.2.2"
},
"peerDependencies": {
"@comapeo/schema": "^1.0.0"
"@comapeo/schema": "^1.1.1"
},
"prettier": {
"semi": false,
Expand Down

0 comments on commit 07c678f

Please sign in to comment.