From 07c678fd45313f679811a5419d0b46291e255f07 Mon Sep 17 00:00:00 2001 From: tomasciccola <117094913+tomasciccola@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:30:50 -0300 Subject: [PATCH] chore: generate remoteDetectionAlert schema, chore: update @comapeo/schema to v1.1.1 (#21) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Co-authored-by: Evan Hahn --- lib/faker.js | 14 ++++++++++++ package-lock.json | 57 ++++++++++++++++++++++++++++++++++++----------- package.json | 3 ++- 3 files changed, 60 insertions(+), 14 deletions(-) diff --git a/lib/faker.js b/lib/faker.js index 641822f..235cafb 100644 --- a/lib/faker.js +++ b/lib/faker.js @@ -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 @@ -167,6 +175,12 @@ function createFakerSchema(schema) { return s } + case 'RemoteDetectionAlert': + s.properties.geometry = { + $ref: Geometry.$id, + ...deref.dereferenceSync(Geometry), + } + return s } } diff --git a/package-lock.json b/package-lock.json index a620601..d2ba852 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@faker-js/faker": "^8.3.1", + "dereference-json-schema": "^0.2.1", "json-schema-faker": "^0.5.3", "type-fest": "^4.8.0" }, @@ -27,7 +28,7 @@ "typescript": "^5.2.2" }, "peerDependencies": { - "@comapeo/schema": "^1.0.0" + "@comapeo/schema": "^1.1.1" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -39,12 +40,22 @@ "node": ">=0.10.0" } }, + "node_modules/@comapeo/geometry": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@comapeo/geometry/-/geometry-1.0.2.tgz", + "integrity": "sha512-q6zadJA3lr85GZPTZ+lol9F6ERRq2Rt4upON7HhcwPPBiCLN696SY03OJZCE6xkXHxjJY98FF5DxVX3W0IftLQ==", + "peer": true, + "dependencies": { + "protobufjs": "^7.4.0" + } + }, "node_modules/@comapeo/schema": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@comapeo/schema/-/schema-1.0.0.tgz", - "integrity": "sha512-dK227I+0yg9D2y5/O5NGywx50tgeNYyUkl1uYnSmNAPlbv+r2KX9aaC9m4dEjIja2aR2VFnYn6z537ERZiahqQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@comapeo/schema/-/schema-1.1.1.tgz", + "integrity": "sha512-pPyzhxv4ROr5bLxUenSiXBqVMT+egPs25IZOwlhvPtoT/RfpH2MrXbWSVoZVpRwhvYWhJykquI9CJaGtyDMUhA==", "peer": true, "dependencies": { + "@comapeo/geometry": "^1.0.2", "compact-encoding": "^2.12.0", "protobufjs": "^7.2.5", "type-fest": "^4.26.0" @@ -600,6 +611,11 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/dereference-json-schema": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/dereference-json-schema/-/dereference-json-schema-0.2.1.tgz", + "integrity": "sha512-uzJsrg225owJyRQ8FNTPHIuBOdSzIZlHhss9u6W8mp7jJldHqGuLv9cULagP/E26QVJDnjtG8U7Dw139mM1ydA==" + }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -1618,9 +1634,9 @@ } }, "node_modules/protobufjs": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.3.2.tgz", - "integrity": "sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz", + "integrity": "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==", "hasInstallScript": true, "peer": true, "dependencies": { @@ -2099,12 +2115,22 @@ "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", "dev": true }, + "@comapeo/geometry": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@comapeo/geometry/-/geometry-1.0.2.tgz", + "integrity": "sha512-q6zadJA3lr85GZPTZ+lol9F6ERRq2Rt4upON7HhcwPPBiCLN696SY03OJZCE6xkXHxjJY98FF5DxVX3W0IftLQ==", + "peer": true, + "requires": { + "protobufjs": "^7.4.0" + } + }, "@comapeo/schema": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@comapeo/schema/-/schema-1.0.0.tgz", - "integrity": "sha512-dK227I+0yg9D2y5/O5NGywx50tgeNYyUkl1uYnSmNAPlbv+r2KX9aaC9m4dEjIja2aR2VFnYn6z537ERZiahqQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@comapeo/schema/-/schema-1.1.1.tgz", + "integrity": "sha512-pPyzhxv4ROr5bLxUenSiXBqVMT+egPs25IZOwlhvPtoT/RfpH2MrXbWSVoZVpRwhvYWhJykquI9CJaGtyDMUhA==", "peer": true, "requires": { + "@comapeo/geometry": "^1.0.2", "compact-encoding": "^2.12.0", "protobufjs": "^7.2.5", "type-fest": "^4.26.0" @@ -2533,6 +2559,11 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "dereference-json-schema": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/dereference-json-schema/-/dereference-json-schema-0.2.1.tgz", + "integrity": "sha512-uzJsrg225owJyRQ8FNTPHIuBOdSzIZlHhss9u6W8mp7jJldHqGuLv9cULagP/E26QVJDnjtG8U7Dw139mM1ydA==" + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -3270,9 +3301,9 @@ "dev": true }, "protobufjs": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.3.2.tgz", - "integrity": "sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz", + "integrity": "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==", "peer": true, "requires": { "@protobufjs/aspromise": "^1.1.2", diff --git a/package.json b/package.json index 84293b0..818ee0f 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -41,7 +42,7 @@ "typescript": "^5.2.2" }, "peerDependencies": { - "@comapeo/schema": "^1.0.0" + "@comapeo/schema": "^1.1.1" }, "prettier": { "semi": false,