diff --git a/package-lock.json b/package-lock.json index 66b0534f4..caf2b8003 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "license": "MIT", "dependencies": { + "@comapeo/schema": "1.0.0", "@digidem/types": "^2.3.0", "@electron/asar": "^3.2.8", "@fastify/error": "^3.4.1", @@ -16,7 +17,6 @@ "@fastify/type-provider-typebox": "^4.0.0", "@hyperswarm/secret-stream": "^6.1.2", "@mapeo/crypto": "1.0.0-alpha.10", - "@mapeo/schema": "3.0.0-next.28", "@mapeo/sqlite-indexer": "1.0.0-alpha.9", "@sinclair/typebox": "^0.29.6", "b4a": "^1.6.3", @@ -59,8 +59,8 @@ }, "devDependencies": { "@bufbuild/buf": "^1.26.1", - "@mapeo/default-config": "4.0.1-alpha.0", - "@mapeo/mock-data": "1.0.3-alpha.7", + "@mapeo/default-config": "5.0.0", + "@mapeo/mock-data": "2.0.0", "@sinonjs/fake-timers": "^10.0.2", "@types/b4a": "^1.6.0", "@types/bogon": "^1.0.2", @@ -241,6 +241,16 @@ "@bufbuild/buf-win32-x64": "1.26.1" } }, + "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==", + "dependencies": { + "compact-encoding": "^2.12.0", + "protobufjs": "^7.2.5", + "type-fest": "^4.26.0" + } + }, "node_modules/@digidem/types": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@digidem/types/-/types-2.3.0.tgz", @@ -781,15 +791,15 @@ } }, "node_modules/@mapeo/default-config": { - "version": "4.0.1-alpha.0", - "resolved": "https://registry.npmjs.org/@mapeo/default-config/-/default-config-4.0.1-alpha.0.tgz", - "integrity": "sha512-8mIqAhNG3/NepSCXhRQB3gMXFXU6gfq/eMlbAvHhwJMLCFpL+77B9aXzgSUEuLsZmGI3yRhc4EGPtxeV+fBPdw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@mapeo/default-config/-/default-config-5.0.0.tgz", + "integrity": "sha512-SNUUxN0UI0i/g5XshUKuLY1O3SWClzwgM3qiiBDW3Dw+AcHK+jdONFK6KjvwYK13cwdQadTzIJbEKWmLP+0UWA==", "dev": true }, "node_modules/@mapeo/mock-data": { - "version": "1.0.3-alpha.7", - "resolved": "https://registry.npmjs.org/@mapeo/mock-data/-/mock-data-1.0.3-alpha.7.tgz", - "integrity": "sha512-ORbX8qMNJRz5QRoOUwYMCcN/34U7R+a66RmVYvqB2FpADEZH19x5IRX5pnQcEVs/iYeA2WROEF7e3PNVM0W48A==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@mapeo/mock-data/-/mock-data-2.0.0.tgz", + "integrity": "sha512-aYB11zpR2mYojUhwMDIhsaBPjzqa7HgEFkf4HNRyAs9N+zKJN4/X3PBm6Q9+QJjAqB0soS363U9j3Kljnu/QIQ==", "dev": true, "dependencies": { "@faker-js/faker": "^8.3.1", @@ -801,45 +811,9 @@ "list-mapeo-schemas": "bin/list-mapeo-schemas.js" }, "peerDependencies": { - "@mapeo/schema": "^3.0.0-next.28" - } - }, - "node_modules/@mapeo/schema": { - "version": "3.0.0-next.28", - "resolved": "https://registry.npmjs.org/@mapeo/schema/-/schema-3.0.0-next.28.tgz", - "integrity": "sha512-yiAaSgJAg9yR3E5YKfkDpE3bChlUmwIdqI+/x8Ly7RYZJ75EHMHA7yBUqSNUYwyPZ0xym6bXZ60Z0T4V41v58g==", - "dependencies": { - "ajv": "^8.12.0", - "compact-encoding": "^2.12.0", - "protobufjs": "^7.2.5", - "type-fest": "^4.26.0" - } - }, - "node_modules/@mapeo/schema/node_modules/ajv": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" + "@comapeo/schema": "^1.0.0" } }, - "node_modules/@mapeo/schema/node_modules/fast-uri": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", - "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==" - }, - "node_modules/@mapeo/schema/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, "node_modules/@mapeo/sqlite-indexer": { "version": "1.0.0-alpha.9", "resolved": "https://registry.npmjs.org/@mapeo/sqlite-indexer/-/sqlite-indexer-1.0.0-alpha.9.tgz", diff --git a/package.json b/package.json index 84b5a7981..0a5f71b32 100644 --- a/package.json +++ b/package.json @@ -108,8 +108,8 @@ "homepage": "https://github.com/digidem/comapeo-core#readme", "devDependencies": { "@bufbuild/buf": "^1.26.1", - "@mapeo/default-config": "4.0.1-alpha.0", - "@mapeo/mock-data": "1.0.3-alpha.7", + "@mapeo/default-config": "5.0.0", + "@mapeo/mock-data": "2.0.0", "@sinonjs/fake-timers": "^10.0.2", "@types/b4a": "^1.6.0", "@types/bogon": "^1.0.2", @@ -158,7 +158,7 @@ "@fastify/type-provider-typebox": "^4.0.0", "@hyperswarm/secret-stream": "^6.1.2", "@mapeo/crypto": "1.0.0-alpha.10", - "@mapeo/schema": "3.0.0-next.28", + "@comapeo/schema": "1.0.0", "@mapeo/sqlite-indexer": "1.0.0-alpha.9", "@sinclair/typebox": "^0.29.6", "b4a": "^1.6.3", diff --git a/src/config-import.js b/src/config-import.js index 6d52f888c..5990dc055 100644 --- a/src/config-import.js +++ b/src/config-import.js @@ -1,5 +1,5 @@ import yauzl from 'yauzl-promise' -import { validate, valueSchemas } from '@mapeo/schema' +import { validate, valueSchemas } from '@comapeo/schema' import { json, buffer } from 'node:stream/consumers' import { assert, isDefined } from './utils.js' import path from 'node:path' @@ -28,7 +28,7 @@ const ICON_NAME_REGEX = /([a-zA-Z0-9-]+)-([a-zA-Z]+)@(\d+)x\.[a-zA-Z]+$/ * }} TranslationsFile */ -/** @typedef {NonNullable} MetadataFile */ +/** @typedef {NonNullable} MetadataFile */ /** * @typedef {Parameters[0]} IconData @@ -121,7 +121,7 @@ export async function readConfig(configPath) { }, /** - * @returns {Iterable<{ name: string, value: import('@mapeo/schema').FieldValue }>} + * @returns {Iterable<{ name: string, value: import('@comapeo/schema').FieldValue }>} */ *fields() { const { fields } = presetsFile @@ -151,7 +151,7 @@ export async function readConfig(configPath) { }, /** - * @returns {Iterable<{ fieldNames: string[], iconName: string | undefined, value: import('@mapeo/schema').PresetValue, name: string}>} + * @returns {Iterable<{ fieldNames: string[], iconName: string | undefined, value: import('@comapeo/schema').PresetValue, name: string}>} */ *presets() { const { presets } = presetsFile @@ -232,7 +232,7 @@ export async function readConfig(configPath) { } } }, - /** @returns {Iterable<{ name: string, value:Omit}>} */ + /** @returns {Iterable<{ name: string, value:Omit}>} */ *translations() { if (!translationsFile) return for (const [lang, languageTranslations] of Object.entries( @@ -365,7 +365,7 @@ function translationsForLanguage(warnings) { /** * schemaNames in configs are in plural but in the schemas are in singular * @param {ValidDocTypes} schemaNamePlural - * @returns {import('@mapeo/schema').TranslationValue['docRefType']} + * @returns {import('@comapeo/schema').TranslationValue['docRefType']} */ function schemaNamePluralToDocRefType(schemaNamePlural) { if (schemaNamePlural === 'fields') return 'field' @@ -382,7 +382,7 @@ function translationsForDocType(warnings) { /** @param {Object} opts * @param {string} opts.languageCode * @param {string | undefined} opts.regionCode - * @param {import('@mapeo/schema').TranslationValue['docRefType']} opts.docRefType + * @param {import('@comapeo/schema').TranslationValue['docRefType']} opts.docRefType * @param {Record} opts.languageTranslationsForDocType */ return function* ({ @@ -417,7 +417,7 @@ function translationForValue(warnings) { * @param {Object} opts * @param {string} opts.languageCode * @param {string | undefined} opts.regionCode - * @param {import('@mapeo/schema').TranslationValue['docRefType']} opts.docRefType + * @param {import('@comapeo/schema').TranslationValue['docRefType']} opts.docRefType * @param {string} opts.docName * @param {Record} opts.fieldsToTranslate */ @@ -460,7 +460,7 @@ function translationForValue(warnings) { function translateMessageObject(warnings) { /** * @param {Object} opts - * @param {Omit} opts.value + * @param {Omit} opts.value * @param {string} opts.docName * @param {Record} opts.message */ diff --git a/src/core-ownership.js b/src/core-ownership.js index f445d2fc2..38a595d28 100644 --- a/src/core-ownership.js +++ b/src/core-ownership.js @@ -1,5 +1,5 @@ import { verifySignature, sign } from '@mapeo/crypto' -import { parseVersionId } from '@mapeo/schema' +import { parseVersionId } from '@comapeo/schema' import { defaultGetWinner } from '@mapeo/sqlite-indexer' import assert from 'node:assert/strict' import sodium from 'sodium-universal' @@ -42,8 +42,8 @@ export class CoreOwnership extends TypedEmitter { * import('./datastore/index.js').DataStore<'auth'>, * typeof import('./schema/project.js').coreOwnershipTable, * 'coreOwnership', - * import('@mapeo/schema').CoreOwnership, - * import('@mapeo/schema').CoreOwnershipValue + * import('@comapeo/schema').CoreOwnership, + * import('@comapeo/schema').CoreOwnershipValue * >} opts.dataType * @param {Record} opts.coreKeypairs * @param {KeyPair} opts.identityKeypair @@ -155,8 +155,8 @@ export class CoreOwnership extends TypedEmitter { * the doc with the lowest index (e.g. the first) * * @param {CoreOwnershipWithSignatures} doc - * @param {import('@mapeo/schema').VersionIdObject} version - * @returns {import('@mapeo/schema').CoreOwnership} + * @param {import('@comapeo/schema').VersionIdObject} version + * @returns {import('@comapeo/schema').CoreOwnership} */ export function mapAndValidateCoreOwnership(doc, { coreDiscoveryKey }) { if ( diff --git a/src/datastore/index.js b/src/datastore/index.js index fc9e6fe87..43712654f 100644 --- a/src/datastore/index.js +++ b/src/datastore/index.js @@ -1,11 +1,11 @@ import { TypedEmitter } from 'tiny-typed-emitter' -import { encode, decode, getVersionId, parseVersionId } from '@mapeo/schema' +import { encode, decode, getVersionId, parseVersionId } from '@comapeo/schema' import MultiCoreIndexer from 'multi-core-indexer' import pDefer from 'p-defer' import { discoveryKey } from 'hypercore-crypto' import { NAMESPACE_SCHEMAS } from '../constants.js' import { createMap } from '../utils.js' -/** @import { MapeoDoc } from '@mapeo/schema' */ +/** @import { MapeoDoc } from '@comapeo/schema' */ /** * For each schemaName in this dataStore, emits an array of docIds that have diff --git a/src/datatype/index.d.ts b/src/datatype/index.d.ts index e29668543..2a6f7d367 100644 --- a/src/datatype/index.d.ts +++ b/src/datatype/index.d.ts @@ -2,7 +2,7 @@ // declaration for DataType is written manually below, and copied into the // `dist` folder at build-time. The types are checked in `test-types/data-types.ts` -import { type MapeoDoc, type MapeoValue } from '@mapeo/schema' +import { type MapeoDoc, type MapeoValue } from '@comapeo/schema' import { type MapeoDocMap, type MapeoValueMap, diff --git a/src/datatype/index.js b/src/datatype/index.js index 4f1ef7144..82459ca2c 100644 --- a/src/datatype/index.js +++ b/src/datatype/index.js @@ -1,4 +1,4 @@ -import { validate } from '@mapeo/schema' +import { validate } from '@comapeo/schema' import { getTableConfig } from 'drizzle-orm/sqlite-core' import { eq, inArray, sql } from 'drizzle-orm' import { randomBytes } from 'node:crypto' @@ -7,7 +7,7 @@ import { NotFoundError } from '../errors.js' import { TypedEmitter } from 'tiny-typed-emitter' import { parse as parseBCP47 } from 'bcp-47' import { setProperty, getProperty } from 'dot-prop' -/** @import { MapeoDoc, MapeoValue } from '@mapeo/schema' */ +/** @import { MapeoDoc, MapeoValue } from '@comapeo/schema' */ /** @import { MapeoDocMap, MapeoValueMap } from '../types.js' */ /** @import { DataStore } from '../datastore/index.js' */ diff --git a/src/fastify-plugins/icons.js b/src/fastify-plugins/icons.js index e8659ba82..39785af77 100644 --- a/src/fastify-plugins/icons.js +++ b/src/fastify-plugins/icons.js @@ -1,6 +1,6 @@ import { Type as T } from '@sinclair/typebox' import fp from 'fastify-plugin' -import { docSchemas } from '@mapeo/schema' +import { docSchemas } from '@comapeo/schema' import { kGetIconBlob } from '../icon-api.js' import { HEX_REGEX_32_BYTES, Z_BASE_32_REGEX_32_BYTES } from './constants.js' @@ -134,7 +134,7 @@ function extractSizeAndPixelDensity(input) { /** * @param {string} value - * @returns {asserts value is Exclude} + * @returns {asserts value is Exclude} */ function assertValidSize(value) { if ( diff --git a/src/icon-api.js b/src/icon-api.js index c690bbe5d..2ecde8089 100644 --- a/src/icon-api.js +++ b/src/icon-api.js @@ -1,4 +1,4 @@ -/** @import { PresetValue, IconValue } from '@mapeo/schema' */ +/** @import { PresetValue, IconValue } from '@comapeo/schema' */ export const kGetIconBlob = Symbol('getIcon') @@ -38,8 +38,8 @@ export class IconApi { * import('./datastore/index.js').DataStore<'config'>, * typeof import('./schema/project.js').iconTable, * 'icon', - * import('@mapeo/schema').Icon, - * import('@mapeo/schema').IconValue + * import('@comapeo/schema').Icon, + * import('@comapeo/schema').IconValue * >} opts.iconDataType * @param {import('./datastore/index.js').DataStore<'config'>} opts.iconDataStore * @param {() => Promise} opts.getMediaBaseUrl @@ -52,10 +52,10 @@ export class IconApi { /** * @param {object} icon - * @param {import('@mapeo/schema').IconValue['name']} icon.name + * @param {import('@comapeo/schema').IconValue['name']} icon.name * @param {Array<(BitmapOpts | SvgOpts) & { blob: Buffer }>} icon.variants * - * @returns {Promise} + * @returns {Promise} */ async create(icon) { if (icon.variants.length < 1) { diff --git a/src/index-writer/index.js b/src/index-writer/index.js index 3024fc166..ae643b99f 100644 --- a/src/index-writer/index.js +++ b/src/index-writer/index.js @@ -1,10 +1,10 @@ -import { decode } from '@mapeo/schema' +import { decode } from '@comapeo/schema' import SqliteIndexer from '@mapeo/sqlite-indexer' import { getTableConfig } from 'drizzle-orm/sqlite-core' import { getBacklinkTableName } from '../schema/utils.js' import { discoveryKey } from 'hypercore-crypto' import { Logger } from '../logger.js' -/** @import { MapeoDoc, VersionIdObject } from '@mapeo/schema' */ +/** @import { MapeoDoc, VersionIdObject } from '@comapeo/schema' */ /** @import { MapeoDocTables } from '../datatype/index.js' */ /** diff --git a/src/mapeo-manager.js b/src/mapeo-manager.js index a33482f28..cdc253f9e 100644 --- a/src/mapeo-manager.js +++ b/src/mapeo-manager.js @@ -48,7 +48,7 @@ import { kRequestFullStop, kRescindFullStopRequest, } from './sync/sync-api.js' -/** @import { ProjectSettingsValue as ProjectValue } from '@mapeo/schema' */ +/** @import { ProjectSettingsValue as ProjectValue } from '@comapeo/schema' */ /** @import { SetNonNullable } from 'type-fest' */ /** @import { CoreStorage, Namespace } from './types.js' */ /** @import { DeviceInfoParam } from './schema/client.js' */ diff --git a/src/mapeo-project.js b/src/mapeo-project.js index 02aed8487..ef8bfba88 100644 --- a/src/mapeo-project.js +++ b/src/mapeo-project.js @@ -1,6 +1,6 @@ import path from 'path' import Database from 'better-sqlite3' -import { decodeBlockPrefix, decode, parseVersionId } from '@mapeo/schema' +import { decodeBlockPrefix, decode, parseVersionId } from '@comapeo/schema' import { drizzle } from 'drizzle-orm/better-sqlite3' import { migrate } from 'drizzle-orm/better-sqlite3/migrator' import { discoveryKey } from 'hypercore-crypto' @@ -49,7 +49,7 @@ import { Logger } from './logger.js' import { IconApi } from './icon-api.js' import { readConfig } from './config-import.js' import TranslationApi from './translation-api.js' -/** @import { ProjectSettingsValue } from '@mapeo/schema' */ +/** @import { ProjectSettingsValue } from '@comapeo/schema' */ /** @import { CoreStorage, KeyPair, Namespace } from './types.js' */ /** @typedef {Omit} EditableProjectSettings */ @@ -600,8 +600,8 @@ export class MapeoProject extends TypedEmitter { } /** - * @param {Pick} value - * @returns {Promise} + * @param {Pick} value + * @returns {Promise} */ async [kSetOwnDeviceInfo](value) { const { deviceInfo } = this.#dataTypes @@ -743,9 +743,9 @@ export class MapeoProject extends TypedEmitter { const config = await readConfig(configPath) /** @type {Map} */ const iconNameToRef = new Map() - /** @type {Map} */ + /** @type {Map} */ const fieldNameToRef = new Map() - /** @type {Map} */ + /** @type {Map} */ const presetNameToRef = new Map() // Do this in serial not parallel to avoid memory issues (avoid keeping all icon buffers in memory) @@ -885,7 +885,7 @@ export class MapeoProject extends TypedEmitter { } /** - * @param {import("@mapeo/schema").ProjectSettings & { forks: string[] }} projectDoc + * @param {import("@comapeo/schema").ProjectSettings & { forks: string[] }} projectDoc * @returns {EditableProjectSettings} */ function extractEditableProjectSettings(projectDoc) { @@ -966,9 +966,9 @@ function getCoreKeypairs({ projectKey, projectSecretKey, keyManager }) { * Validate that a deviceInfo record is written by the device that is it about, * e.g. version.coreKey should equal docId * - * @param {import('@mapeo/schema').DeviceInfo} doc - * @param {import('@mapeo/schema').VersionIdObject} version - * @returns {import('@mapeo/schema').DeviceInfo} + * @param {import('@comapeo/schema').DeviceInfo} doc + * @param {import('@comapeo/schema').VersionIdObject} version + * @returns {import('@comapeo/schema').DeviceInfo} */ function mapAndValidateDeviceInfo(doc, { coreDiscoveryKey }) { if (!coreDiscoveryKey.equals(discoveryKey(Buffer.from(doc.docId, 'hex')))) { diff --git a/src/member-api.js b/src/member-api.js index 7dcd80646..75627555a 100644 --- a/src/member-api.js +++ b/src/member-api.js @@ -18,7 +18,7 @@ import { ROLES, isRoleIdForNewInvite } from './roles.js' * DeviceInfoValue, * ProjectSettings, * ProjectSettingsValue - * } from '@mapeo/schema' + * } from '@comapeo/schema' */ /** @import { Invite, InviteResponse } from './generated/rpc.js' */ /** @import { DataType } from './datatype/index.js' */ diff --git a/src/roles.js b/src/roles.js index b2304eb4b..f3aa6566e 100644 --- a/src/roles.js +++ b/src/roles.js @@ -1,4 +1,4 @@ -import { currentSchemaVersions } from '@mapeo/schema' +import { currentSchemaVersions } from '@comapeo/schema' import mapObject from 'map-obj' import { kCreateWithDocId, kDataStore } from './datatype/index.js' import { assert, setHas } from './utils.js' @@ -67,7 +67,7 @@ const isRoleIdAssignableToAnyone = setHas(ROLE_IDS_ASSIGNABLE_TO_ANYONE) * @typedef {object} Role * @property {T} roleId * @property {string} name - * @property {Record} docs + * @property {Record} docs * @property {RoleIdAssignableToOthers[]} roleAssignment * @property {Record} sync */ @@ -239,8 +239,8 @@ export class Roles extends TypedEmitter { * import('./datastore/index.js').DataStore<'auth'>, * typeof import('./schema/project.js').roleTable, * 'role', - * import('@mapeo/schema').Role, - * import('@mapeo/schema').RoleValue + * import('@comapeo/schema').Role, + * import('@comapeo/schema').RoleValue * >} opts.dataType * @param {import('./core-ownership.js').CoreOwnership} opts.coreOwnership * @param {import('./core-manager/index.js').CoreManager} opts.coreManager diff --git a/src/schema/client.js b/src/schema/client.js index d5164f32f..8aa25efbf 100644 --- a/src/schema/client.js +++ b/src/schema/client.js @@ -2,7 +2,7 @@ // database and it contains information that is shared across all projects on a // device import { blob, sqliteTable, text } from 'drizzle-orm/sqlite-core' -import { dereferencedDocSchemas as schemas } from '@mapeo/schema' +import { dereferencedDocSchemas as schemas } from '@comapeo/schema' import { jsonSchemaToDrizzleColumns as toColumns } from './schema-to-drizzle.js' import { backlinkTable, customJson } from './utils.js' @@ -40,7 +40,7 @@ export const projectKeysTable = sqliteTable('projectKeys', { }) /** - * @typedef {Omit} DeviceInfoParam + * @typedef {Omit} DeviceInfoParam */ const deviceInfoColumn = diff --git a/src/schema/project.js b/src/schema/project.js index 4ee2ca5b1..facd85f9b 100644 --- a/src/schema/project.js +++ b/src/schema/project.js @@ -1,7 +1,7 @@ // These schemas are all in a "project" database. Each project in Mapeo has an // independent "project" database. import { blob, sqliteTable, text } from 'drizzle-orm/sqlite-core' -import { dereferencedDocSchemas as schemas } from '@mapeo/schema' +import { dereferencedDocSchemas as schemas } from '@comapeo/schema' import { NAMESPACES } from '../constants.js' import { jsonSchemaToDrizzleColumns as toColumns } from './schema-to-drizzle.js' import { backlinkTable } from './utils.js' diff --git a/src/schema/schema-to-drizzle.js b/src/schema/schema-to-drizzle.js index 9b07e17dc..2de9e3ab5 100644 --- a/src/schema/schema-to-drizzle.js +++ b/src/schema/schema-to-drizzle.js @@ -1,7 +1,7 @@ import { text, integer, real } from 'drizzle-orm/sqlite-core' import { ExhaustivenessError } from '../utils.js' import { customJson } from './utils.js' -/** @import { MapeoDoc } from '@mapeo/schema' */ +/** @import { MapeoDoc } from '@comapeo/schema' */ /** @import { MapeoDocMap } from '../types.js' */ /** @@ -70,7 +70,7 @@ export function jsonSchemaToDrizzleColumns(schema) { } } } - // Not yet in @mapeo/schema + // Not yet in @comapeo/schema columns.forks = customJson('forks').notNull() return /** @type {any} */ (columns) } diff --git a/src/sync/sync-api.js b/src/sync/sync-api.js index 7002bae31..bffa26863 100644 --- a/src/sync/sync-api.js +++ b/src/sync/sync-api.js @@ -9,7 +9,7 @@ import { } from '../constants.js' import { ExhaustivenessError, assert, keyToId, noop } from '../utils.js' import { NO_ROLE_ID } from '../roles.js' -/** @import { CoreOwnership as CoreOwnershipDoc } from '@mapeo/schema' */ +/** @import { CoreOwnership as CoreOwnershipDoc } from '@comapeo/schema' */ /** @import { CoreOwnership } from '../core-ownership.js' */ /** @import { OpenedNoiseStream } from '../lib/noise-secret-stream-helpers.js' */ diff --git a/src/translation-api.js b/src/translation-api.js index 288d065e4..12929a9a8 100644 --- a/src/translation-api.js +++ b/src/translation-api.js @@ -2,7 +2,7 @@ import { and, sql } from 'drizzle-orm' import { kCreateWithDocId, kSelect } from './datatype/index.js' import { hashObject } from './utils.js' import { NotFoundError } from './errors.js' -/** @import { Translation, TranslationValue } from '@mapeo/schema' */ +/** @import { Translation, TranslationValue } from '@comapeo/schema' */ /** @import { SetOptional } from 'type-fest' */ export const ktranslatedLanguageCodeToSchemaNames = Symbol( @@ -11,7 +11,7 @@ export const ktranslatedLanguageCodeToSchemaNames = Symbol( export default class TranslationApi { /** @type {Map< * TranslationValue['languageCode'], - * Set>} */ + * Set>} */ #translatedLanguageCodeToSchemaNames = new Map() #dataType #table @@ -71,7 +71,7 @@ export default class TranslationApi { * @param {SetOptional< * Omit, * 'propertyRef' | 'regionCode'> & {docRef: DocRefWithOptionalVersionId}} value - * @returns {Promise} + * @returns {Promise} */ async get(value) { await this.ready() @@ -80,7 +80,7 @@ export default class TranslationApi { this.#translatedLanguageCodeToSchemaNames .get(value.languageCode) ?.has( - /** @type {import('@mapeo/schema/dist/types.js').SchemaName} */ ( + /** @type {import('@comapeo/schema/dist/types.js').SchemaName} */ ( value.docRefType ) ) @@ -125,7 +125,7 @@ export default class TranslationApi { ) } translatedSchemas.add( - /** @type {import('@mapeo/schema/dist/types.js').SchemaName} */ ( + /** @type {import('@comapeo/schema/dist/types.js').SchemaName} */ ( doc.docRefType ) ) diff --git a/src/types.ts b/src/types.ts index 1a6914634..48d94b587 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,7 +6,7 @@ import type { SetOptional, } from 'type-fest' import { SUPPORTED_BLOB_VARIANTS } from './blob-store/index.js' -import { MapeoCommon, MapeoDoc, MapeoValue, decode } from '@mapeo/schema' +import { MapeoCommon, MapeoDoc, MapeoValue, decode } from '@comapeo/schema' import type BigSparseArray from 'big-sparse-array' import type Protomux from 'protomux' import type NoiseStream from '@hyperswarm/secret-stream' @@ -55,7 +55,7 @@ export type MapeoValueMap = { [K in MapeoValue['schemaName']]: Extract } -// TODO: Replace this with exports from @mapeo/schema +// TODO: Replace this with exports from @comapeo/schema export type CoreOwnershipWithSignatures = Extract< ReturnType, { schemaName: 'coreOwnership' } @@ -95,7 +95,7 @@ export type MapBuffers = { * Make any properties whose value include `null` optional, and remove `null` * from the type. This converts the types returned from SQLite (which have all * top-level optional props set to `null`) to the original types in - * @mapeo/schema + * @comapeo/schema */ export type NullableToOptional = Simplify>> export type KeyPair = { diff --git a/src/utils.js b/src/utils.js index 2a86bbf4e..d1ee17b70 100644 --- a/src/utils.js +++ b/src/utils.js @@ -99,7 +99,7 @@ export function isDefined(value) { /** * When reading from SQLite, any optional properties are set to `null`. This * converts `null` back to `undefined` to match the input types (e.g. the types - * defined in @mapeo/schema) + * defined in @comapeo/schema) * @template {{}} T * @param {T} obj * @returns {import('./types.js').NullableToOptional} @@ -115,7 +115,7 @@ export function deNullify(obj) { } /** - * @template {import('@mapeo/schema').MapeoDoc & { forks?: string[] }} T + * @template {import('@comapeo/schema').MapeoDoc & { forks?: string[] }} T * @param {T} doc * @returns {Omit} */ diff --git a/test-e2e/core-ownership.js b/test-e2e/core-ownership.js index 9b1cba122..e79e7005b 100644 --- a/test-e2e/core-ownership.js +++ b/test-e2e/core-ownership.js @@ -2,7 +2,7 @@ import test from 'node:test' import assert from 'node:assert/strict' import { KeyManager } from '@mapeo/crypto' import { generate } from '@mapeo/mock-data' -import { parseVersionId, valueOf } from '@mapeo/schema' +import { parseVersionId, valueOf } from '@comapeo/schema' import RAM from 'random-access-memory' import { discoveryKey } from 'hypercore-crypto' import Fastify from 'fastify' diff --git a/test-e2e/fixtures/translations.js b/test-e2e/fixtures/translations.js index 5727b313e..d21f75977 100644 --- a/test-e2e/fixtures/translations.js +++ b/test-e2e/fixtures/translations.js @@ -1,7 +1,7 @@ const commonPreset = { /** @type {'translation'} */ schemaName: 'translation', - /** @type {import('@mapeo/schema').TranslationValue['docRefType']} */ + /** @type {import('@comapeo/schema').TranslationValue['docRefType']} */ docRefType: 'preset', languageCode: 'es', regionCode: 'AR', @@ -11,7 +11,7 @@ const commonPreset = { const commonField = { /** @type {'translation'} */ schemaName: 'translation', - /** @type {import('@mapeo/schema').TranslationValue['docRefType']} */ + /** @type {import('@comapeo/schema').TranslationValue['docRefType']} */ docRefType: 'field', languageCode: 'es', regionCode: 'AR', diff --git a/test-e2e/original_version_id_to_device_id.js b/test-e2e/original_version_id_to_device_id.js index 0c8c075fe..aa13f9a51 100644 --- a/test-e2e/original_version_id_to_device_id.js +++ b/test-e2e/original_version_id_to_device_id.js @@ -1,5 +1,5 @@ import { generate } from '@mapeo/mock-data' -import { valueOf } from '@mapeo/schema' +import { valueOf } from '@comapeo/schema' import assert from 'node:assert/strict' import test from 'node:test' import { diff --git a/test-e2e/project-crud.js b/test-e2e/project-crud.js index ea9634395..9ef3ef151 100644 --- a/test-e2e/project-crud.js +++ b/test-e2e/project-crud.js @@ -13,9 +13,9 @@ import { import { round } from './utils.js' import { generate } from '@mapeo/mock-data' import { setTimeout as delay } from 'timers/promises' -/** @import { MapeoDoc } from '@mapeo/schema' */ +/** @import { MapeoDoc } from '@comapeo/schema' */ -/** @satisfies {Array} */ +/** @satisfies {Array} */ const fixtures = [ { schemaName: 'observation', @@ -58,7 +58,7 @@ const fixtures = [ /** * Add some random data to each fixture to test updates * - * @template {import('@mapeo/schema').MapeoValue} T + * @template {import('@comapeo/schema').MapeoValue} T * @param {T} value * @returns {T} */ diff --git a/test-e2e/project-leave.js b/test-e2e/project-leave.js index c69ca8b59..72a208cb1 100644 --- a/test-e2e/project-leave.js +++ b/test-e2e/project-leave.js @@ -4,7 +4,7 @@ import * as fs from 'node:fs/promises' import { temporaryDirectory } from 'tempy' import { generate } from '@mapeo/mock-data' -import { valueOf } from '@mapeo/schema' +import { valueOf } from '@comapeo/schema' import { BLOCKED_ROLE_ID, COORDINATOR_ROLE_ID, diff --git a/test-e2e/utils.js b/test-e2e/utils.js index 2d1f5691b..5c8e40ec9 100644 --- a/test-e2e/utils.js +++ b/test-e2e/utils.js @@ -165,7 +165,11 @@ export const waitForPeers = (managers, { waitForDeviceInfo = false } = {}) => * @param {import('../src/generated/rpc.js').DeviceInfo['deviceType']} [deviceType] * @returns {Promise>} */ -export async function createManagers(count, t, deviceType) { +export async function createManagers( + count, + t, + deviceType = 'device_type_unspecified' +) { // @ts-ignore return Promise.all( Array(count) @@ -173,7 +177,6 @@ export async function createManagers(count, t, deviceType) { .map(async (_, i) => { const name = 'device' + i + (deviceType ? `-${deviceType}` : '') const manager = createManager(name, t) - // @ts-ignore TODO: remove after updating @mapeo/schema await manager.setDeviceInfo({ name, deviceType }) return manager }) @@ -468,7 +471,7 @@ export function waitForSync(projects, type = 'initial') { /** * @param {import('../src/mapeo-project.js').MapeoProject[]} projects * @param {object} [opts] - * @param {readonly import('@mapeo/schema').MapeoDoc['schemaName'][]} [opts.schemas] + * @param {readonly import('@comapeo/schema').MapeoDoc['schemaName'][]} [opts.schemas] */ export function seedDatabases(projects, { schemas = SCHEMAS_TO_SEED } = {}) { return Promise.all(projects.map((p) => seedProjectDatabase(p, { schemas }))) @@ -483,8 +486,8 @@ const SCHEMAS_TO_SEED = /** @type {const} */ ([ /** * @param {import('../src/mapeo-project.js').MapeoProject} project * @param {object} [opts] - * @param {readonly import('@mapeo/schema').MapeoDoc['schemaName'][]} [opts.schemas] - * @returns {Promise>} + * @param {readonly import('@comapeo/schema').MapeoDoc['schemaName'][]} [opts.schemas] + * @returns {Promise>} */ async function seedProjectDatabase( project, @@ -563,7 +566,7 @@ export async function getExpectedConfig(path) { } } -/** @param {import('@mapeo/schema').MapeoDoc[]} docs */ +/** @param {import('@comapeo/schema').MapeoDoc[]} docs */ export function sortById(docs) { return sortBy(docs, 'docId') } diff --git a/test-types/data-types.ts b/test-types/data-types.ts index be2c90e56..5ec5e340d 100644 --- a/test-types/data-types.ts +++ b/test-types/data-types.ts @@ -10,7 +10,7 @@ import { PresetValue, Track, TrackValue, -} from '@mapeo/schema' +} from '@comapeo/schema' import Database from 'better-sqlite3' import { drizzle } from 'drizzle-orm/better-sqlite3' import RAM from 'random-access-memory' diff --git a/test-types/schema.ts b/test-types/schema.ts index 4e7d27fc5..42977c79d 100644 --- a/test-types/schema.ts +++ b/test-types/schema.ts @@ -1,7 +1,7 @@ import { drizzle } from 'drizzle-orm/better-sqlite3' import Database from 'better-sqlite3' import { deNullify } from '../src/utils.js' -import type { MapeoDoc, MapeoValue } from '@mapeo/schema' +import type { MapeoDoc, MapeoValue } from '@comapeo/schema' import * as projectTableSchemas from '../src/schema/project.js' const sqlite = new Database(':memory:') diff --git a/tests/core-ownership.js b/tests/core-ownership.js index e3a44e0c6..bcee185fd 100644 --- a/tests/core-ownership.js +++ b/tests/core-ownership.js @@ -7,7 +7,7 @@ import { getWinner, } from '../src/core-ownership.js' import { randomBytes } from 'node:crypto' -import { parseVersionId, getVersionId } from '@mapeo/schema' +import { parseVersionId, getVersionId } from '@comapeo/schema' import { discoveryKey } from 'hypercore-crypto' /** @import { Namespace } from '../src/types.js' */ @@ -177,7 +177,7 @@ function generateValidDoc() { blob: km.getHypercoreKeypair('blob', projectKey), } - /** @type {ReturnType} */ + /** @type {ReturnType} */ const validDoc = { docId: km.getIdentityKeypair().publicKey.toString('hex'), versionId: getVersionId({ diff --git a/tests/data-type.js b/tests/data-type.js index 3f051f6ec..7080fe53e 100644 --- a/tests/data-type.js +++ b/tests/data-type.js @@ -19,9 +19,9 @@ import { migrate } from 'drizzle-orm/better-sqlite3/migrator' import { randomBytes } from 'crypto' import TranslationApi from '../src/translation-api.js' import { getProperty } from 'dot-prop' -import { decode, decodeBlockPrefix, parseVersionId } from '@mapeo/schema' +import { decode, decodeBlockPrefix, parseVersionId } from '@comapeo/schema' -/** @type {import('@mapeo/schema').ObservationValue} */ +/** @type {import('@comapeo/schema').ObservationValue} */ const obsFixture = { schemaName: 'observation', lat: -3, @@ -31,7 +31,7 @@ const obsFixture = { metadata: { manualLocation: false }, } -/** @type {import('@mapeo/schema').ObservationValue} */ +/** @type {import('@comapeo/schema').ObservationValue} */ const newObsFixture = { schemaName: 'observation', lat: -1, @@ -178,7 +178,7 @@ test('validity of `originalVersionId` from another peer', async () => { assert.equal(replicatedObservation.originalVersionId, obs.originalVersionId) - /** @type {import('@mapeo/schema').ObservationValue} */ + /** @type {import('@comapeo/schema').ObservationValue} */ const newObsFixture = { schemaName: 'observation', lat: -3, @@ -225,7 +225,7 @@ test('delete()', async () => { test('translation', async () => { const projectKey = randomBytes(32) const { dataType, translationApi } = await testenv({ projectKey }) - /** @type {import('@mapeo/schema').ObservationValue} */ + /** @type {import('@comapeo/schema').ObservationValue} */ const observation = { schemaName: 'observation', lat: -3, @@ -241,7 +241,7 @@ test('translation', async () => { const translation = { /** @type {'translation'} */ schemaName: 'translation', - /** @type {import('@mapeo/schema').TranslationValue['docRefType']} */ + /** @type {import('@comapeo/schema').TranslationValue['docRefType']} */ docRefType: 'observation', docRef: { docId: doc.docId, versionId: doc.versionId }, propertyRef: 'tags.type', diff --git a/tests/datastore.js b/tests/datastore.js index 01c0bc131..57440d375 100644 --- a/tests/datastore.js +++ b/tests/datastore.js @@ -3,12 +3,12 @@ import assert from 'node:assert/strict' import { randomBytes } from 'node:crypto' import { DataStore } from '../src/datastore/index.js' import { createCoreManager } from './helpers/core-manager.js' -import { getVersionId } from '@mapeo/schema' +import { getVersionId } from '@comapeo/schema' import { once } from 'events' import RAM from 'random-access-memory' import { discoveryKey } from 'hypercore-crypto' -/** @type {Omit} */ +/** @type {Omit} */ const obs = { docId: 'abc', originalVersionId: getVersionId({ diff --git a/tests/icon-api.js b/tests/icon-api.js index b60a62b02..6f8402f28 100644 --- a/tests/icon-api.js +++ b/tests/icon-api.js @@ -317,7 +317,7 @@ test('getBestVariant() - specify size', async (t) => { }) await t.test('request size with match present', () => { - /** @type {Array<[import('../src/icon-api.js').ValidSizes, import('@mapeo/schema').Icon['variants'][number]]>} */ + /** @type {Array<[import('../src/icon-api.js').ValidSizes, import('@comapeo/schema').Icon['variants'][number]]>} */ const pairs = [ ['small', smallVariant], ['medium', mediumVariant], @@ -402,7 +402,7 @@ test('getBestVariant() - specify size', async (t) => { }) test('getBestVariant() - specify pixel density', async (t) => { - /** @type {Pick & + /** @type {Pick & * {size: import('../src/icon-api.js').ValidSizes}} */ const common = { size: 'small', mimeType: 'image/png' } @@ -422,7 +422,7 @@ test('getBestVariant() - specify pixel density', async (t) => { }) await t.test('request pixel density with match present', () => { - /** @type {Array<[import('../src/icon-api.js').BitmapOpts['pixelDensity'], import('@mapeo/schema').Icon['variants'][number]]>} */ + /** @type {Array<[import('../src/icon-api.js').BitmapOpts['pixelDensity'], import('@comapeo/schema').Icon['variants'][number]]>} */ const pairs = [ [1, density1Variant], [2, density2Variant], @@ -713,7 +713,7 @@ function createRandomVersionId(index = 0) { /** * @param {import('../src/icon-api.js').BitmapOpts | import('../src/icon-api.js').SvgOpts} opts - * @returns {import('@mapeo/schema').Icon['variants'][number]} + * @returns {import('@comapeo/schema').Icon['variants'][number]} */ function createIconVariant(opts) { return { diff --git a/tests/schema.js b/tests/schema.js index 9c155e515..2c98d01b2 100644 --- a/tests/schema.js +++ b/tests/schema.js @@ -3,7 +3,7 @@ import assert from 'node:assert/strict' import { getTableConfig } from 'drizzle-orm/sqlite-core' import * as clientTableSchemas from '../src/schema/client.js' import * as projectTableSchemas from '../src/schema/project.js' -import { dereferencedDocSchemas as jsonSchemas } from '@mapeo/schema' +import { dereferencedDocSchemas as jsonSchemas } from '@comapeo/schema' import { BACKLINK_TABLE_POSTFIX, getBacklinkTableName, diff --git a/tests/translation-api.js b/tests/translation-api.js index 5a4c9a5f1..7f6a616d3 100644 --- a/tests/translation-api.js +++ b/tests/translation-api.js @@ -21,7 +21,7 @@ test('translation api - put() and get()', async () => { const doc = { /** @type {'translation'} */ schemaName: 'translation', - /** @type {import('@mapeo/schema').TranslationValue['docRefType']} */ + /** @type {import('@comapeo/schema').TranslationValue['docRefType']} */ docRefType: 'field', docRef: { docId: randomBytes(32).toString('hex'), @@ -81,7 +81,7 @@ test('translation api - put() and get()', async () => { const newDoc = { /** @type {'translation'} */ schemaName: 'translation', - /** @type {import('@mapeo/schema').TranslationValue['docRefType']} */ + /** @type {import('@comapeo/schema').TranslationValue['docRefType']} */ docRefType: 'field', docRef: { docId: randomBytes(32).toString('hex'),