From b38c096d88340080ec02277bc772c1269b6b65fd Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Fri, 15 Mar 2024 21:48:18 +0000 Subject: [PATCH] refactor(schema-type,protocol-parser): explicit internal vs external exports (#2452) --- .changeset/honest-singers-tickle.md | 6 +++++ e2e/packages/sync-test/data/encodeTestData.ts | 2 +- e2e/packages/sync-test/data/types.ts | 2 +- packages/cli/src/deploy/configToTables.ts | 4 +-- packages/cli/src/deploy/ensureTables.ts | 2 +- packages/cli/src/deploy/getFunctions.ts | 2 +- packages/cli/src/deploy/getResourceAccess.ts | 2 +- packages/cli/src/deploy/getTableValue.ts | 2 +- packages/cli/src/deploy/getTables.ts | 2 +- packages/cli/src/deploy/resolveConfig.ts | 4 +-- .../src/codegen/utils/loadUserTypesFile.ts | 2 +- packages/config/package.json | 6 ++++- packages/config/src/common.ts | 2 +- packages/config/src/exports/index.ts | 7 +++++ packages/config/src/exports/internal.ts | 0 packages/config/src/index.ts | 1 - packages/config/tsup.config.ts | 3 ++- packages/dev-tools/src/zustand/FieldValue.tsx | 2 +- packages/protocol-parser/package.json | 14 ++++++++-- .../protocol-parser/src/abiTypesToSchema.ts | 2 +- packages/protocol-parser/src/common.ts | 7 ++++- .../protocol-parser/src/decodeDynamicField.ts | 2 +- packages/protocol-parser/src/decodeField.ts | 2 +- .../protocol-parser/src/decodeKeyTuple.ts | 2 +- packages/protocol-parser/src/decodeRecord.ts | 2 +- .../protocol-parser/src/decodeStaticField.ts | 2 +- packages/protocol-parser/src/decodeValue.ts | 2 +- .../protocol-parser/src/decodeValueArgs.ts | 2 +- packages/protocol-parser/src/encodeField.ts | 2 +- packages/protocol-parser/src/encodeKey.ts | 2 +- .../protocol-parser/src/encodeKeyTuple.ts | 2 +- packages/protocol-parser/src/encodeRecord.ts | 2 +- .../protocol-parser/src/encodeValueArgs.ts | 2 +- packages/protocol-parser/src/errors.ts | 2 +- packages/protocol-parser/src/exports/index.ts | 5 ++++ .../protocol-parser/src/exports/internal.ts | 27 +++++++++++++++++++ packages/protocol-parser/src/hexToSchema.ts | 7 ++++- packages/protocol-parser/src/index.ts | 27 ------------------- .../protocol-parser/src/keySchemaToHex.ts | 2 +- .../src/schemaIndexToAbiType.ts | 2 +- packages/protocol-parser/src/schemaToHex.ts | 2 +- .../protocol-parser/src/staticDataLength.ts | 2 +- .../src/valueSchemaToFieldLayoutHex.ts | 2 +- .../protocol-parser/src/valueSchemaToHex.ts | 2 +- packages/protocol-parser/tsup.config.ts | 5 +++- packages/query/src/api.ts | 2 +- packages/query/src/common.ts | 2 +- packages/schema-type/package.json | 12 ++++++--- .../src/typescript/deprecated/index.ts | 4 --- .../src/typescript/exports/deprecated.ts | 4 +++ .../src/typescript/exports/index.ts | 5 ++++ .../src/typescript/exports/internal.ts | 6 +++++ packages/schema-type/src/typescript/index.ts | 6 ----- packages/schema-type/tsup.config.ts | 8 ++++-- .../postgres/deprecated/createQueryAdapter.ts | 2 +- .../store-indexer/src/postgres/recordToLog.ts | 2 +- .../src/sqlite/getTablesWithRecords.ts | 2 +- packages/store-sync/src/common.ts | 2 +- packages/store-sync/src/logToTable.ts | 2 +- .../src/postgres-decoded/buildColumn.ts | 2 +- .../src/postgres-decoded/buildTable.ts | 2 +- .../postgres-decoded/createStorageAdapter.ts | 2 +- .../src/postgres-decoded/getTables.ts | 2 +- packages/store-sync/src/query-cache/common.ts | 2 +- .../src/query-cache/createStorageAdapter.ts | 2 +- .../store-sync/src/query-cache/createStore.ts | 2 +- packages/store-sync/src/recs/common.ts | 2 +- packages/store-sync/src/recs/decodeEntity.ts | 2 +- packages/store-sync/src/recs/encodeEntity.ts | 2 +- packages/store-sync/src/recs/recsStorage.ts | 2 +- .../src/recs/schemaAbiTypeToRecsType.ts | 2 +- .../store-sync/src/recs/tableToComponent.ts | 2 +- packages/store-sync/src/schemaToDefaults.ts | 4 +-- packages/store-sync/src/sqlite/buildColumn.ts | 2 +- packages/store-sync/src/sqlite/buildTable.ts | 2 +- .../store-sync/src/sqlite/internalTables.ts | 2 +- .../store-sync/src/sqlite/sqliteStorage.ts | 2 +- packages/store-sync/src/tableToLog.ts | 2 +- .../store-sync/src/tablesWithRecordsToLogs.ts | 2 +- .../src/zustand/createStorageAdapter.ts | 2 +- .../store-sync/src/zustand/createStore.ts | 2 +- packages/store-sync/src/zustand/logToTable.ts | 2 +- packages/store/ts/codegen/renderTable.ts | 2 +- .../codegen/tightcoder/renderDecodeSlice.ts | 2 +- .../codegen/tightcoder/renderEncodeArray.ts | 2 +- .../tightcoder/renderTightCoderAutoTest.ts | 2 +- packages/store/ts/common.ts | 2 +- .../ts/config/experimental/resolveConfig.ts | 2 +- packages/store/ts/config/storeConfig.ts | 2 +- packages/store/ts/config/v2/scope.ts | 2 +- packages/store/ts/config/v2/store.ts | 2 +- packages/store/ts/config/v2/tableFull.ts | 2 +- packages/store/ts/config/v2/tableShorthand.ts | 2 +- 93 files changed, 185 insertions(+), 127 deletions(-) create mode 100644 .changeset/honest-singers-tickle.md create mode 100644 packages/config/src/exports/index.ts create mode 100644 packages/config/src/exports/internal.ts delete mode 100644 packages/config/src/index.ts create mode 100644 packages/protocol-parser/src/exports/index.ts create mode 100644 packages/protocol-parser/src/exports/internal.ts delete mode 100644 packages/protocol-parser/src/index.ts delete mode 100644 packages/schema-type/src/typescript/deprecated/index.ts create mode 100644 packages/schema-type/src/typescript/exports/deprecated.ts create mode 100644 packages/schema-type/src/typescript/exports/index.ts create mode 100644 packages/schema-type/src/typescript/exports/internal.ts delete mode 100644 packages/schema-type/src/typescript/index.ts diff --git a/.changeset/honest-singers-tickle.md b/.changeset/honest-singers-tickle.md new file mode 100644 index 0000000000..fe5e6a9cdb --- /dev/null +++ b/.changeset/honest-singers-tickle.md @@ -0,0 +1,6 @@ +--- +"@latticexyz/protocol-parser": major +"@latticexyz/schema-type": major +--- + +Moved all existing exports to a `/internal` import path to indicate that these are now internal-only and deprecated. We'll be replacing these types and functions with new ones that are compatible with our new, strongly-typed config. diff --git a/e2e/packages/sync-test/data/encodeTestData.ts b/e2e/packages/sync-test/data/encodeTestData.ts index 891d770dc4..1ff78b6cb5 100644 --- a/e2e/packages/sync-test/data/encodeTestData.ts +++ b/e2e/packages/sync-test/data/encodeTestData.ts @@ -1,5 +1,5 @@ import { mapObject } from "@latticexyz/utils"; -import { encodeKey, encodeValueArgs, valueSchemaToFieldLayoutHex } from "@latticexyz/protocol-parser"; +import { encodeKey, encodeValueArgs, valueSchemaToFieldLayoutHex } from "@latticexyz/protocol-parser/internal"; import { Data, EncodedData } from "./types"; import config from "../../contracts/mud.config"; diff --git a/e2e/packages/sync-test/data/types.ts b/e2e/packages/sync-test/data/types.ts index 98369a7426..84a38cc93f 100644 --- a/e2e/packages/sync-test/data/types.ts +++ b/e2e/packages/sync-test/data/types.ts @@ -1,5 +1,5 @@ // Note: this expects the config to not use shortcuts but the full definitions for table schemas -import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type"; +import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal"; import config from "../../contracts/mud.config"; import { Hex } from "viem"; type SchemaToPrimitive = diff --git a/packages/cli/src/deploy/configToTables.ts b/packages/cli/src/deploy/configToTables.ts index 43e942bbf8..f69e7f9cf0 100644 --- a/packages/cli/src/deploy/configToTables.ts +++ b/packages/cli/src/deploy/configToTables.ts @@ -1,6 +1,6 @@ import { resourceToHex } from "@latticexyz/common"; -import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser"; -import { SchemaAbiType, StaticAbiType } from "@latticexyz/schema-type"; +import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser/internal"; +import { SchemaAbiType, StaticAbiType } from "@latticexyz/schema-type/internal"; import { StoreConfig, resolveUserTypes } from "@latticexyz/store"; import { Hex } from "viem"; diff --git a/packages/cli/src/deploy/ensureTables.ts b/packages/cli/src/deploy/ensureTables.ts index 0ab65681bd..6fa4416c29 100644 --- a/packages/cli/src/deploy/ensureTables.ts +++ b/packages/cli/src/deploy/ensureTables.ts @@ -2,7 +2,7 @@ import { Client, Transport, Chain, Account, Hex } from "viem"; import { Table } from "./configToTables"; import { resourceToLabel, writeContract } from "@latticexyz/common"; import { WorldDeploy, worldAbi } from "./common"; -import { valueSchemaToFieldLayoutHex, keySchemaToHex, valueSchemaToHex } from "@latticexyz/protocol-parser"; +import { valueSchemaToFieldLayoutHex, keySchemaToHex, valueSchemaToHex } from "@latticexyz/protocol-parser/internal"; import { debug } from "./debug"; import { getTables } from "./getTables"; import pRetry from "p-retry"; diff --git a/packages/cli/src/deploy/getFunctions.ts b/packages/cli/src/deploy/getFunctions.ts index f191f41ec8..3ee7b0462e 100644 --- a/packages/cli/src/deploy/getFunctions.ts +++ b/packages/cli/src/deploy/getFunctions.ts @@ -3,7 +3,7 @@ import { WorldDeploy, WorldFunction, worldTables } from "./common"; import { debug } from "./debug"; import { storeSetRecordEvent } from "@latticexyz/store"; import { getLogs } from "viem/actions"; -import { decodeValueArgs } from "@latticexyz/protocol-parser"; +import { decodeValueArgs } from "@latticexyz/protocol-parser/internal"; import { getTableValue } from "./getTableValue"; import { hexToResource } from "@latticexyz/common"; diff --git a/packages/cli/src/deploy/getResourceAccess.ts b/packages/cli/src/deploy/getResourceAccess.ts index a9642085be..56a2dbba8a 100644 --- a/packages/cli/src/deploy/getResourceAccess.ts +++ b/packages/cli/src/deploy/getResourceAccess.ts @@ -3,7 +3,7 @@ import { WorldDeploy, worldTables } from "./common"; import { debug } from "./debug"; import { storeSpliceStaticDataEvent } from "@latticexyz/store"; import { getLogs } from "viem/actions"; -import { decodeKey } from "@latticexyz/protocol-parser"; +import { decodeKey } from "@latticexyz/protocol-parser/internal"; import { getTableValue } from "./getTableValue"; export async function getResourceAccess({ diff --git a/packages/cli/src/deploy/getTableValue.ts b/packages/cli/src/deploy/getTableValue.ts index 7f5440a149..8221df17d4 100644 --- a/packages/cli/src/deploy/getTableValue.ts +++ b/packages/cli/src/deploy/getTableValue.ts @@ -1,4 +1,4 @@ -import { SchemaToPrimitives, decodeValueArgs, encodeKey } from "@latticexyz/protocol-parser"; +import { SchemaToPrimitives, decodeValueArgs, encodeKey } from "@latticexyz/protocol-parser/internal"; import { WorldDeploy, worldAbi } from "./common"; import { Client } from "viem"; import { readContract } from "viem/actions"; diff --git a/packages/cli/src/deploy/getTables.ts b/packages/cli/src/deploy/getTables.ts index 3342c7b9db..660c593c1a 100644 --- a/packages/cli/src/deploy/getTables.ts +++ b/packages/cli/src/deploy/getTables.ts @@ -5,7 +5,7 @@ import { WorldDeploy, storeTables } from "./common"; import { debug } from "./debug"; import { storeSetRecordEvent } from "@latticexyz/store"; import { getLogs } from "viem/actions"; -import { KeySchema, ValueSchema, decodeKey, decodeValueArgs, hexToSchema } from "@latticexyz/protocol-parser"; +import { KeySchema, ValueSchema, decodeKey, decodeValueArgs, hexToSchema } from "@latticexyz/protocol-parser/internal"; export async function getTables({ client, diff --git a/packages/cli/src/deploy/resolveConfig.ts b/packages/cli/src/deploy/resolveConfig.ts index cbfb5c7f38..64adee54c9 100644 --- a/packages/cli/src/deploy/resolveConfig.ts +++ b/packages/cli/src/deploy/resolveConfig.ts @@ -3,8 +3,8 @@ import { resolveWorldConfig } from "@latticexyz/world"; import { Config, ConfigInput, Library, Module, System, WorldFunction } from "./common"; import { resourceToHex } from "@latticexyz/common"; import { resolveWithContext } from "@latticexyz/config/library"; -import { encodeField } from "@latticexyz/protocol-parser"; -import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type"; +import { encodeField } from "@latticexyz/protocol-parser/internal"; +import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal"; import { Hex, hexToBytes, bytesToHex, toFunctionSelector, toFunctionSignature } from "viem"; import { getExistingContracts } from "../utils/getExistingContracts"; import { defaultModuleContracts } from "../utils/defaultModuleContracts"; diff --git a/packages/common/src/codegen/utils/loadUserTypesFile.ts b/packages/common/src/codegen/utils/loadUserTypesFile.ts index 127299d92f..f08608daf3 100644 --- a/packages/common/src/codegen/utils/loadUserTypesFile.ts +++ b/packages/common/src/codegen/utils/loadUserTypesFile.ts @@ -2,7 +2,7 @@ import { readFileSync } from "fs"; import path from "path"; import { SolidityUserDefinedType, extractUserTypes } from "./extractUserTypes"; import { MUDError } from "../../errors"; -import { SchemaAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType } from "@latticexyz/schema-type/internal"; export type UserType = { filePath: string; diff --git a/packages/config/package.json b/packages/config/package.json index 68f348e9ec..11dd08bac5 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -11,6 +11,7 @@ "type": "module", "exports": { ".": "./dist/index.js", + "./internal": "./dist/internal.js", "./library": "./dist/deprecated/library.js", "./register": "./dist/deprecated/register.js", "./node": "./dist/deprecated/node.js" @@ -18,7 +19,10 @@ "typesVersions": { "*": { "index": [ - "./src/index.ts" + "./src/exports/index.ts" + ], + "internal": [ + "./src/exports/internal.ts" ], "library": [ "./src/deprecated/library/index.ts" diff --git a/packages/config/src/common.ts b/packages/config/src/common.ts index 639fe84fee..037a910698 100644 --- a/packages/config/src/common.ts +++ b/packages/config/src/common.ts @@ -1,5 +1,5 @@ import { Hex } from "viem"; -import { DynamicAbiType, StaticAbiType } from "@latticexyz/schema-type"; +import { DynamicAbiType, StaticAbiType } from "@latticexyz/schema-type/internal"; import { ResourceType } from "@latticexyz/common"; import { satisfy } from "@latticexyz/common/type-utils"; diff --git a/packages/config/src/exports/index.ts b/packages/config/src/exports/index.ts new file mode 100644 index 0000000000..a6770a967a --- /dev/null +++ b/packages/config/src/exports/index.ts @@ -0,0 +1,7 @@ +/** + * External exports. + * + * Be sure you're ready to commit to these being supported and changes made backward compatible! + */ + +export type { AbiType, StaticAbiType, DynamicAbiType, Schema, Table } from "../common"; diff --git a/packages/config/src/exports/internal.ts b/packages/config/src/exports/internal.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts deleted file mode 100644 index 6b57160892..0000000000 --- a/packages/config/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./common"; diff --git a/packages/config/tsup.config.ts b/packages/config/tsup.config.ts index acd6fbcc1e..b758b036c8 100644 --- a/packages/config/tsup.config.ts +++ b/packages/config/tsup.config.ts @@ -2,7 +2,8 @@ import { defineConfig } from "tsup"; export default defineConfig({ entry: { - index: "src/index.ts", + index: "src/exports/index.ts", + internal: "src/exports/internal.ts", "deprecated/library": "src/deprecated/library/index.ts", "deprecated/register": "src/deprecated/register/index.ts", "deprecated/node": "src/deprecated/node/index.ts", diff --git a/packages/dev-tools/src/zustand/FieldValue.tsx b/packages/dev-tools/src/zustand/FieldValue.tsx index 7922151da6..41f0b7095e 100644 --- a/packages/dev-tools/src/zustand/FieldValue.tsx +++ b/packages/dev-tools/src/zustand/FieldValue.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type"; +import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal"; import { isHex } from "viem"; import { TruncatedHex } from "../TruncatedHex"; diff --git a/packages/protocol-parser/package.json b/packages/protocol-parser/package.json index 08ca13b9d8..18ff70aac4 100644 --- a/packages/protocol-parser/package.json +++ b/packages/protocol-parser/package.json @@ -10,9 +10,19 @@ "license": "MIT", "type": "module", "exports": { - ".": "./dist/index.js" + ".": "./dist/index.js", + "./internal": "./dist/internal.js" + }, + "typesVersions": { + "*": { + "index": [ + "./src/exports/index.ts" + ], + "internal": [ + "./src/exports/internal.ts" + ] + } }, - "types": "src/index.ts", "scripts": { "build": "pnpm run build:js", "build:js": "tsup", diff --git a/packages/protocol-parser/src/abiTypesToSchema.ts b/packages/protocol-parser/src/abiTypesToSchema.ts index 1dc2077ac9..ee5fbe6014 100644 --- a/packages/protocol-parser/src/abiTypesToSchema.ts +++ b/packages/protocol-parser/src/abiTypesToSchema.ts @@ -1,4 +1,4 @@ -import { DynamicAbiType, SchemaAbiType, StaticAbiType, isDynamicAbiType } from "@latticexyz/schema-type"; +import { DynamicAbiType, SchemaAbiType, StaticAbiType, isDynamicAbiType } from "@latticexyz/schema-type/internal"; import { Schema } from "./common"; export function abiTypesToSchema(abiTypes: SchemaAbiType[]): Schema { diff --git a/packages/protocol-parser/src/common.ts b/packages/protocol-parser/src/common.ts index 9eccf8f792..8922bbac9c 100644 --- a/packages/protocol-parser/src/common.ts +++ b/packages/protocol-parser/src/common.ts @@ -1,4 +1,9 @@ -import { DynamicAbiType, SchemaAbiType, SchemaAbiTypeToPrimitiveType, StaticAbiType } from "@latticexyz/schema-type"; +import { + DynamicAbiType, + SchemaAbiType, + SchemaAbiTypeToPrimitiveType, + StaticAbiType, +} from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; /** @deprecated use `KeySchema` or `ValueSchema` instead */ diff --git a/packages/protocol-parser/src/decodeDynamicField.ts b/packages/protocol-parser/src/decodeDynamicField.ts index d9eaf52b64..f674bd86dd 100644 --- a/packages/protocol-parser/src/decodeDynamicField.ts +++ b/packages/protocol-parser/src/decodeDynamicField.ts @@ -5,7 +5,7 @@ import { DynamicAbiTypeToPrimitiveType, arrayAbiTypeToStaticAbiType, staticAbiTypeToByteLength, -} from "@latticexyz/schema-type"; +} from "@latticexyz/schema-type/internal"; import { decodeStaticField } from "./decodeStaticField"; import { InvalidHexLengthError, InvalidHexLengthForArrayFieldError } from "./errors"; diff --git a/packages/protocol-parser/src/decodeField.ts b/packages/protocol-parser/src/decodeField.ts index e6b6d881c7..6473e00bfd 100644 --- a/packages/protocol-parser/src/decodeField.ts +++ b/packages/protocol-parser/src/decodeField.ts @@ -1,5 +1,5 @@ import { Hex } from "viem"; -import { SchemaAbiType, SchemaAbiTypeToPrimitiveType, isDynamicAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType, SchemaAbiTypeToPrimitiveType, isDynamicAbiType } from "@latticexyz/schema-type/internal"; import { decodeDynamicField } from "./decodeDynamicField"; import { decodeStaticField } from "./decodeStaticField"; diff --git a/packages/protocol-parser/src/decodeKeyTuple.ts b/packages/protocol-parser/src/decodeKeyTuple.ts index 426806dd68..093cbae36d 100644 --- a/packages/protocol-parser/src/decodeKeyTuple.ts +++ b/packages/protocol-parser/src/decodeKeyTuple.ts @@ -1,5 +1,5 @@ import { Hex, decodeAbiParameters } from "viem"; -import { StaticPrimitiveType } from "@latticexyz/schema-type"; +import { StaticPrimitiveType } from "@latticexyz/schema-type/internal"; import { Schema } from "./common"; // key tuples are encoded in the same way as abi.encode, so we can decode them with viem diff --git a/packages/protocol-parser/src/decodeRecord.ts b/packages/protocol-parser/src/decodeRecord.ts index 1ae389fbcf..07cc48d6d5 100644 --- a/packages/protocol-parser/src/decodeRecord.ts +++ b/packages/protocol-parser/src/decodeRecord.ts @@ -3,7 +3,7 @@ import { DynamicPrimitiveType, staticAbiTypeToByteLength, dynamicAbiTypeToDefaultValue, -} from "@latticexyz/schema-type"; +} from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { Schema } from "./common"; import { decodeDynamicField } from "./decodeDynamicField"; diff --git a/packages/protocol-parser/src/decodeStaticField.ts b/packages/protocol-parser/src/decodeStaticField.ts index 9d2819d307..f20f8d11da 100644 --- a/packages/protocol-parser/src/decodeStaticField.ts +++ b/packages/protocol-parser/src/decodeStaticField.ts @@ -5,7 +5,7 @@ import { StaticAbiTypeToPrimitiveType, staticAbiTypeToByteLength, staticAbiTypeToDefaultValue, -} from "@latticexyz/schema-type"; +} from "@latticexyz/schema-type/internal"; import { InvalidHexLengthError, InvalidHexLengthForStaticFieldError } from "./errors"; export function decodeStaticField< diff --git a/packages/protocol-parser/src/decodeValue.ts b/packages/protocol-parser/src/decodeValue.ts index 06bb1a4b4a..74fcf7d357 100644 --- a/packages/protocol-parser/src/decodeValue.ts +++ b/packages/protocol-parser/src/decodeValue.ts @@ -1,4 +1,4 @@ -import { isStaticAbiType, isDynamicAbiType } from "@latticexyz/schema-type"; +import { isStaticAbiType, isDynamicAbiType } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { SchemaToPrimitives, ValueSchema } from "./common"; import { decodeRecord } from "./decodeRecord"; diff --git a/packages/protocol-parser/src/decodeValueArgs.ts b/packages/protocol-parser/src/decodeValueArgs.ts index 62966ba93d..ee3b64f016 100644 --- a/packages/protocol-parser/src/decodeValueArgs.ts +++ b/packages/protocol-parser/src/decodeValueArgs.ts @@ -1,5 +1,5 @@ import { concatHex } from "viem"; -import { isStaticAbiType } from "@latticexyz/schema-type"; +import { isStaticAbiType } from "@latticexyz/schema-type/internal"; import { SchemaToPrimitives, ValueArgs, ValueSchema } from "./common"; import { decodeValue } from "./decodeValue"; import { staticDataLength } from "./staticDataLength"; diff --git a/packages/protocol-parser/src/encodeField.ts b/packages/protocol-parser/src/encodeField.ts index cacfda1caf..d650c5ffe3 100644 --- a/packages/protocol-parser/src/encodeField.ts +++ b/packages/protocol-parser/src/encodeField.ts @@ -1,4 +1,4 @@ -import { SchemaAbiType, arrayAbiTypeToStaticAbiType, isArrayAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType, arrayAbiTypeToStaticAbiType, isArrayAbiType } from "@latticexyz/schema-type/internal"; import { AbiParameterToPrimitiveType } from "abitype"; import { Hex, encodePacked } from "viem"; diff --git a/packages/protocol-parser/src/encodeKey.ts b/packages/protocol-parser/src/encodeKey.ts index f520536eae..fd384e8c64 100644 --- a/packages/protocol-parser/src/encodeKey.ts +++ b/packages/protocol-parser/src/encodeKey.ts @@ -1,4 +1,4 @@ -import { isStaticAbiType } from "@latticexyz/schema-type"; +import { isStaticAbiType } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { SchemaToPrimitives, KeySchema } from "./common"; import { encodeKeyTuple } from "./encodeKeyTuple"; diff --git a/packages/protocol-parser/src/encodeKeyTuple.ts b/packages/protocol-parser/src/encodeKeyTuple.ts index e81337cac0..1e15a33716 100644 --- a/packages/protocol-parser/src/encodeKeyTuple.ts +++ b/packages/protocol-parser/src/encodeKeyTuple.ts @@ -1,4 +1,4 @@ -import { StaticPrimitiveType } from "@latticexyz/schema-type"; +import { StaticPrimitiveType } from "@latticexyz/schema-type/internal"; import { Hex, encodeAbiParameters } from "viem"; import { Schema } from "./common"; diff --git a/packages/protocol-parser/src/encodeRecord.ts b/packages/protocol-parser/src/encodeRecord.ts index 6c0e0f4daf..46d2cee65f 100644 --- a/packages/protocol-parser/src/encodeRecord.ts +++ b/packages/protocol-parser/src/encodeRecord.ts @@ -1,4 +1,4 @@ -import { StaticPrimitiveType, DynamicPrimitiveType } from "@latticexyz/schema-type"; +import { StaticPrimitiveType, DynamicPrimitiveType } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { encodeField } from "./encodeField"; import { Schema } from "./common"; diff --git a/packages/protocol-parser/src/encodeValueArgs.ts b/packages/protocol-parser/src/encodeValueArgs.ts index bc0723f93f..d7c4753af2 100644 --- a/packages/protocol-parser/src/encodeValueArgs.ts +++ b/packages/protocol-parser/src/encodeValueArgs.ts @@ -5,7 +5,7 @@ import { isDynamicAbiType, StaticAbiType, DynamicAbiType, -} from "@latticexyz/schema-type"; +} from "@latticexyz/schema-type/internal"; import { concatHex } from "viem"; import { encodeField } from "./encodeField"; import { SchemaToPrimitives, ValueArgs, ValueSchema } from "./common"; diff --git a/packages/protocol-parser/src/errors.ts b/packages/protocol-parser/src/errors.ts index 168d0eb93d..a3c10857a5 100644 --- a/packages/protocol-parser/src/errors.ts +++ b/packages/protocol-parser/src/errors.ts @@ -1,6 +1,6 @@ import { Hex } from "viem"; import { MUDError } from "@latticexyz/common/errors"; -import { StaticAbiType, staticAbiTypeToByteLength } from "@latticexyz/schema-type"; +import { StaticAbiType, staticAbiTypeToByteLength } from "@latticexyz/schema-type/internal"; export class InvalidHexLengthError extends MUDError { override name = "InvalidHexValueError"; diff --git a/packages/protocol-parser/src/exports/index.ts b/packages/protocol-parser/src/exports/index.ts new file mode 100644 index 0000000000..88c5f97806 --- /dev/null +++ b/packages/protocol-parser/src/exports/index.ts @@ -0,0 +1,5 @@ +/** + * External exports. + * + * Be sure you're ready to commit to these being supported and changes made backward compatible! + */ diff --git a/packages/protocol-parser/src/exports/internal.ts b/packages/protocol-parser/src/exports/internal.ts new file mode 100644 index 0000000000..c544214b56 --- /dev/null +++ b/packages/protocol-parser/src/exports/internal.ts @@ -0,0 +1,27 @@ +export * from "../abiTypesToSchema"; +export * from "../common"; +export * from "../decodeDynamicField"; +export * from "../decodeField"; +export * from "../decodeKey"; +export * from "../decodeKeyTuple"; +export * from "../decodeRecord"; +export * from "../decodeStaticField"; +export * from "../decodeValue"; +export * from "../decodeValueArgs"; +export * from "../encodeField"; +export * from "../encodeKey"; +export * from "../encodeKeyTuple"; +export * from "../encodeRecord"; +export * from "../encodeValue"; +export * from "../encodeValueArgs"; +export * from "../errors"; +export * from "../fieldLayoutToHex"; +export * from "../hexToPackedCounter"; +export * from "../hexToSchema"; +export * from "../hexToTableSchema"; +export * from "../keySchemaToHex"; +export * from "../schemaIndexToAbiType"; +export * from "../schemaToHex"; +export * from "../staticDataLength"; +export * from "../valueSchemaToFieldLayoutHex"; +export * from "../valueSchemaToHex"; diff --git a/packages/protocol-parser/src/hexToSchema.ts b/packages/protocol-parser/src/hexToSchema.ts index b0b74211bb..0336033d09 100644 --- a/packages/protocol-parser/src/hexToSchema.ts +++ b/packages/protocol-parser/src/hexToSchema.ts @@ -1,4 +1,9 @@ -import { StaticAbiType, DynamicAbiType, schemaAbiTypes, staticAbiTypeToByteLength } from "@latticexyz/schema-type"; +import { + StaticAbiType, + DynamicAbiType, + schemaAbiTypes, + staticAbiTypeToByteLength, +} from "@latticexyz/schema-type/internal"; import { Hex, hexToNumber, sliceHex } from "viem"; import { Schema } from "./common"; import { InvalidHexLengthForSchemaError, SchemaStaticLengthMismatchError } from "./errors"; diff --git a/packages/protocol-parser/src/index.ts b/packages/protocol-parser/src/index.ts deleted file mode 100644 index 9874481e71..0000000000 --- a/packages/protocol-parser/src/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -export * from "./abiTypesToSchema"; -export * from "./common"; -export * from "./decodeDynamicField"; -export * from "./decodeField"; -export * from "./decodeKey"; -export * from "./decodeKeyTuple"; -export * from "./decodeRecord"; -export * from "./decodeStaticField"; -export * from "./decodeValue"; -export * from "./decodeValueArgs"; -export * from "./encodeField"; -export * from "./encodeKey"; -export * from "./encodeKeyTuple"; -export * from "./encodeRecord"; -export * from "./encodeValue"; -export * from "./encodeValueArgs"; -export * from "./errors"; -export * from "./fieldLayoutToHex"; -export * from "./hexToPackedCounter"; -export * from "./hexToSchema"; -export * from "./hexToTableSchema"; -export * from "./keySchemaToHex"; -export * from "./schemaIndexToAbiType"; -export * from "./schemaToHex"; -export * from "./staticDataLength"; -export * from "./valueSchemaToFieldLayoutHex"; -export * from "./valueSchemaToHex"; diff --git a/packages/protocol-parser/src/keySchemaToHex.ts b/packages/protocol-parser/src/keySchemaToHex.ts index f2e9443153..35fd8bcc60 100644 --- a/packages/protocol-parser/src/keySchemaToHex.ts +++ b/packages/protocol-parser/src/keySchemaToHex.ts @@ -1,4 +1,4 @@ -import { isStaticAbiType } from "@latticexyz/schema-type"; +import { isStaticAbiType } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { KeySchema } from "./common"; import { schemaToHex } from "./schemaToHex"; diff --git a/packages/protocol-parser/src/schemaIndexToAbiType.ts b/packages/protocol-parser/src/schemaIndexToAbiType.ts index b06a08634b..3691b18ec1 100644 --- a/packages/protocol-parser/src/schemaIndexToAbiType.ts +++ b/packages/protocol-parser/src/schemaIndexToAbiType.ts @@ -1,4 +1,4 @@ -import { SchemaAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType } from "@latticexyz/schema-type/internal"; import { Schema } from "./common"; export function schemaIndexToAbiType(schema: Schema, schemaIndex: number): SchemaAbiType { diff --git a/packages/protocol-parser/src/schemaToHex.ts b/packages/protocol-parser/src/schemaToHex.ts index 439994d17c..432f769c0c 100644 --- a/packages/protocol-parser/src/schemaToHex.ts +++ b/packages/protocol-parser/src/schemaToHex.ts @@ -1,4 +1,4 @@ -import { schemaAbiTypes } from "@latticexyz/schema-type"; +import { schemaAbiTypes } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { Schema } from "./common"; import { staticDataLength } from "./staticDataLength"; diff --git a/packages/protocol-parser/src/staticDataLength.ts b/packages/protocol-parser/src/staticDataLength.ts index aeb28f4115..b376d8b735 100644 --- a/packages/protocol-parser/src/staticDataLength.ts +++ b/packages/protocol-parser/src/staticDataLength.ts @@ -1,4 +1,4 @@ -import { StaticAbiType, staticAbiTypeToByteLength } from "@latticexyz/schema-type"; +import { StaticAbiType, staticAbiTypeToByteLength } from "@latticexyz/schema-type/internal"; export function staticDataLength(staticFields: readonly StaticAbiType[]): number { return staticFields.reduce((length, fieldType) => length + staticAbiTypeToByteLength[fieldType], 0); diff --git a/packages/protocol-parser/src/valueSchemaToFieldLayoutHex.ts b/packages/protocol-parser/src/valueSchemaToFieldLayoutHex.ts index dc10d95944..9d8b9f429b 100644 --- a/packages/protocol-parser/src/valueSchemaToFieldLayoutHex.ts +++ b/packages/protocol-parser/src/valueSchemaToFieldLayoutHex.ts @@ -1,6 +1,6 @@ import { Hex } from "viem"; import { ValueSchema } from "./common"; -import { isDynamicAbiType, isStaticAbiType, staticAbiTypeToByteLength } from "@latticexyz/schema-type"; +import { isDynamicAbiType, isStaticAbiType, staticAbiTypeToByteLength } from "@latticexyz/schema-type/internal"; // TODO: add tests once we have corresponding tests for FieldLayout.sol (bytes32 -> FieldLayout and vice versa) export function valueSchemaToFieldLayoutHex(valueSchema: ValueSchema): Hex { diff --git a/packages/protocol-parser/src/valueSchemaToHex.ts b/packages/protocol-parser/src/valueSchemaToHex.ts index 205b8696ea..e667767ffc 100644 --- a/packages/protocol-parser/src/valueSchemaToHex.ts +++ b/packages/protocol-parser/src/valueSchemaToHex.ts @@ -1,4 +1,4 @@ -import { isDynamicAbiType, isStaticAbiType } from "@latticexyz/schema-type"; +import { isDynamicAbiType, isStaticAbiType } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { ValueSchema } from "./common"; import { schemaToHex } from "./schemaToHex"; diff --git a/packages/protocol-parser/tsup.config.ts b/packages/protocol-parser/tsup.config.ts index 52bdfceee6..bb7fe3066b 100644 --- a/packages/protocol-parser/tsup.config.ts +++ b/packages/protocol-parser/tsup.config.ts @@ -1,7 +1,10 @@ import { defineConfig } from "tsup"; export default defineConfig({ - entry: ["src/index.ts"], + entry: { + index: "src/exports/index.ts", + internal: "src/exports/internal.ts", + }, target: "esnext", format: ["esm"], dts: true, diff --git a/packages/query/src/api.ts b/packages/query/src/api.ts index ecc5c37d5f..eb3be879ef 100644 --- a/packages/query/src/api.ts +++ b/packages/query/src/api.ts @@ -1,5 +1,5 @@ import { Hex } from "viem"; -import { StaticPrimitiveType, DynamicPrimitiveType, SchemaAbiType } from "@latticexyz/schema-type"; +import { StaticPrimitiveType, DynamicPrimitiveType, SchemaAbiType } from "@latticexyz/schema-type/internal"; import { satisfy } from "@latticexyz/common/type-utils"; import { SchemaToPrimitives } from "@latticexyz/store"; import { Table } from "@latticexyz/store/config/v2"; diff --git a/packages/query/src/common.ts b/packages/query/src/common.ts index a3a14d8c50..cc8508da6d 100644 --- a/packages/query/src/common.ts +++ b/packages/query/src/common.ts @@ -1,4 +1,4 @@ -import { StaticPrimitiveType } from "@latticexyz/schema-type"; +import { StaticPrimitiveType } from "@latticexyz/schema-type/internal"; import { SchemaToPrimitives } from "@latticexyz/store"; import { Table } from "@latticexyz/store/config/v2"; import { Hex } from "viem"; diff --git a/packages/schema-type/package.json b/packages/schema-type/package.json index caedfb79e0..05de9f3dfe 100644 --- a/packages/schema-type/package.json +++ b/packages/schema-type/package.json @@ -10,16 +10,20 @@ "license": "MIT", "type": "module", "exports": { - ".": "./dist/typescript/index.js", - "./deprecated": "./dist/typescript/deprecated/index.js" + ".": "./dist/index.js", + "./internal": "./dist/internal.js", + "./deprecated": "./dist/deprecated.js" }, "typesVersions": { "*": { "index": [ - "./src/typescript/index.ts" + "./src/typescript/exports/index.ts" + ], + "internal": [ + "./src/typescript/exports/internal.ts" ], "deprecated": [ - "./src/typescript/deprecated/index.ts" + "./src/typescript/exports/deprecated.ts" ] } }, diff --git a/packages/schema-type/src/typescript/deprecated/index.ts b/packages/schema-type/src/typescript/deprecated/index.ts deleted file mode 100644 index 0a2694e637..0000000000 --- a/packages/schema-type/src/typescript/deprecated/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./types"; -export * from "./mappings"; -export * from "./utils"; -export * from "./SchemaType"; diff --git a/packages/schema-type/src/typescript/exports/deprecated.ts b/packages/schema-type/src/typescript/exports/deprecated.ts new file mode 100644 index 0000000000..edb6a9db94 --- /dev/null +++ b/packages/schema-type/src/typescript/exports/deprecated.ts @@ -0,0 +1,4 @@ +export * from "../deprecated/types"; +export * from "../deprecated/mappings"; +export * from "../deprecated/utils"; +export * from "../deprecated/SchemaType"; diff --git a/packages/schema-type/src/typescript/exports/index.ts b/packages/schema-type/src/typescript/exports/index.ts new file mode 100644 index 0000000000..88c5f97806 --- /dev/null +++ b/packages/schema-type/src/typescript/exports/index.ts @@ -0,0 +1,5 @@ +/** + * External exports. + * + * Be sure you're ready to commit to these being supported and changes made backward compatible! + */ diff --git a/packages/schema-type/src/typescript/exports/internal.ts b/packages/schema-type/src/typescript/exports/internal.ts new file mode 100644 index 0000000000..99aa24fb09 --- /dev/null +++ b/packages/schema-type/src/typescript/exports/internal.ts @@ -0,0 +1,6 @@ +export * from "../arrayAbiTypes"; +export * from "../dynamicAbiTypes"; +export * from "../schemaAbiTypes"; +export * from "../schemaAbiTypeToDefaultValue"; +export * from "../staticAbiTypes"; +export * from "../schemaAbiTypeToPrimitiveType"; diff --git a/packages/schema-type/src/typescript/index.ts b/packages/schema-type/src/typescript/index.ts deleted file mode 100644 index eafb2eb6e6..0000000000 --- a/packages/schema-type/src/typescript/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./arrayAbiTypes"; -export * from "./dynamicAbiTypes"; -export * from "./schemaAbiTypes"; -export * from "./schemaAbiTypeToDefaultValue"; -export * from "./staticAbiTypes"; -export * from "./schemaAbiTypeToPrimitiveType"; diff --git a/packages/schema-type/tsup.config.ts b/packages/schema-type/tsup.config.ts index 4ae11283a7..757d933b24 100644 --- a/packages/schema-type/tsup.config.ts +++ b/packages/schema-type/tsup.config.ts @@ -1,8 +1,12 @@ import { defineConfig } from "tsup"; export default defineConfig({ - entry: ["src/typescript/index.ts", "src/typescript/deprecated/index.ts"], - outDir: "dist/typescript", + entry: { + index: "src/typescript/exports/index.ts", + internal: "src/typescript/exports/internal.ts", + deprecated: "src/typescript/exports/deprecated.ts", + }, + outDir: "dist", target: "esnext", format: ["esm"], dts: true, diff --git a/packages/store-indexer/src/postgres/deprecated/createQueryAdapter.ts b/packages/store-indexer/src/postgres/deprecated/createQueryAdapter.ts index d318f8e01d..977be3e482 100644 --- a/packages/store-indexer/src/postgres/deprecated/createQueryAdapter.ts +++ b/packages/store-indexer/src/postgres/deprecated/createQueryAdapter.ts @@ -1,7 +1,7 @@ import { getAddress } from "viem"; import { PgDatabase } from "drizzle-orm/pg-core"; import { TableWithRecords, isTableRegistrationLog, logToTable, storeTables } from "@latticexyz/store-sync"; -import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser"; +import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser/internal"; import { QueryAdapter } from "@latticexyz/store-sync/trpc-indexer"; import { debug } from "../../debug"; import { getLogs } from "./getLogs"; diff --git a/packages/store-indexer/src/postgres/recordToLog.ts b/packages/store-indexer/src/postgres/recordToLog.ts index b74ec281d3..4c9ca7c74e 100644 --- a/packages/store-indexer/src/postgres/recordToLog.ts +++ b/packages/store-indexer/src/postgres/recordToLog.ts @@ -1,5 +1,5 @@ import { StorageAdapterLog } from "@latticexyz/store-sync"; -import { decodeDynamicField } from "@latticexyz/protocol-parser"; +import { decodeDynamicField } from "@latticexyz/protocol-parser/internal"; import { RecordData } from "./common"; export function recordToLog( diff --git a/packages/store-indexer/src/sqlite/getTablesWithRecords.ts b/packages/store-indexer/src/sqlite/getTablesWithRecords.ts index 504f2561a2..a3de2112ae 100644 --- a/packages/store-indexer/src/sqlite/getTablesWithRecords.ts +++ b/packages/store-indexer/src/sqlite/getTablesWithRecords.ts @@ -2,7 +2,7 @@ import { asc, eq } from "drizzle-orm"; import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core"; import { buildTable, chainState, getTables } from "@latticexyz/store-sync/sqlite"; import { Hex, getAddress } from "viem"; -import { decodeDynamicField } from "@latticexyz/protocol-parser"; +import { decodeDynamicField } from "@latticexyz/protocol-parser/internal"; import { SyncFilter, TableWithRecords } from "@latticexyz/store-sync"; // TODO: refactor sqlite and replace this with getLogs to match postgres (https://github.com/latticexyz/mud/issues/1970) diff --git a/packages/store-sync/src/common.ts b/packages/store-sync/src/common.ts index f0d05866e1..8c86305fb7 100644 --- a/packages/store-sync/src/common.ts +++ b/packages/store-sync/src/common.ts @@ -2,7 +2,7 @@ import { Address, Block, Hex, Log, PublicClient } from "viem"; import { StoreConfig, StoreEventsAbiItem, StoreEventsAbi, resolveConfig } from "@latticexyz/store"; import { Observable } from "rxjs"; import { UnionPick } from "@latticexyz/common/type-utils"; -import { KeySchema, TableRecord, ValueSchema } from "@latticexyz/protocol-parser"; +import { KeySchema, TableRecord, ValueSchema } from "@latticexyz/protocol-parser/internal"; import storeConfig from "@latticexyz/store/mud.config"; import worldConfig from "@latticexyz/world/mud.config"; import { flattenSchema } from "./flattenSchema"; diff --git a/packages/store-sync/src/logToTable.ts b/packages/store-sync/src/logToTable.ts index c69e616186..6e9e1f5c47 100644 --- a/packages/store-sync/src/logToTable.ts +++ b/packages/store-sync/src/logToTable.ts @@ -1,4 +1,4 @@ -import { hexToSchema, decodeValue, ValueSchema } from "@latticexyz/protocol-parser"; +import { hexToSchema, decodeValue, ValueSchema } from "@latticexyz/protocol-parser/internal"; import { Hex, concatHex, decodeAbiParameters, parseAbiParameters } from "viem"; import { StorageAdapterLog, Table, schemasTable } from "./common"; import { hexToResource } from "@latticexyz/common"; diff --git a/packages/store-sync/src/postgres-decoded/buildColumn.ts b/packages/store-sync/src/postgres-decoded/buildColumn.ts index 33a8925f55..22387b086c 100644 --- a/packages/store-sync/src/postgres-decoded/buildColumn.ts +++ b/packages/store-sync/src/postgres-decoded/buildColumn.ts @@ -1,5 +1,5 @@ import { boolean, text } from "drizzle-orm/pg-core"; -import { SchemaAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType } from "@latticexyz/schema-type/internal"; import { assertExhaustive } from "@latticexyz/common/utils"; import { asAddress, diff --git a/packages/store-sync/src/postgres-decoded/buildTable.ts b/packages/store-sync/src/postgres-decoded/buildTable.ts index 2db76ee6bc..115be4b6d0 100644 --- a/packages/store-sync/src/postgres-decoded/buildTable.ts +++ b/packages/store-sync/src/postgres-decoded/buildTable.ts @@ -1,7 +1,7 @@ import { PgColumnBuilderBase, PgTableWithColumns, pgSchema } from "drizzle-orm/pg-core"; import { Address } from "viem"; import { snakeCase } from "change-case"; -import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser"; +import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser/internal"; import { asBigInt, asHex } from "../postgres/columnTypes"; import { transformSchemaName } from "../postgres/transformSchemaName"; import { buildColumn } from "./buildColumn"; diff --git a/packages/store-sync/src/postgres-decoded/createStorageAdapter.ts b/packages/store-sync/src/postgres-decoded/createStorageAdapter.ts index d14401ef89..321362b674 100644 --- a/packages/store-sync/src/postgres-decoded/createStorageAdapter.ts +++ b/packages/store-sync/src/postgres-decoded/createStorageAdapter.ts @@ -7,7 +7,7 @@ import { debug } from "./debug"; import { StorageAdapter, StorageAdapterBlock } from "../common"; import { isTableRegistrationLog } from "../isTableRegistrationLog"; import { logToTable } from "../logToTable"; -import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser"; +import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser/internal"; import { tables as internalTables } from "../postgres/tables"; import { createStorageAdapter as createBytesStorageAdapter } from "../postgres/createStorageAdapter"; import { setupTables } from "../postgres/setupTables"; diff --git a/packages/store-sync/src/postgres-decoded/getTables.ts b/packages/store-sync/src/postgres-decoded/getTables.ts index ff75b70764..0ea9e1ce8c 100644 --- a/packages/store-sync/src/postgres-decoded/getTables.ts +++ b/packages/store-sync/src/postgres-decoded/getTables.ts @@ -3,7 +3,7 @@ import { and, eq, or } from "drizzle-orm"; import { Table, storeTables } from "../common"; import { tables as internalTables } from "../postgres/tables"; import { Hex } from "viem"; -import { decodeDynamicField } from "@latticexyz/protocol-parser"; +import { decodeDynamicField } from "@latticexyz/protocol-parser/internal"; import { logToTable } from "../logToTable"; export async function getTables( diff --git a/packages/store-sync/src/query-cache/common.ts b/packages/store-sync/src/query-cache/common.ts index b5bd29b12d..4fdb6f29e3 100644 --- a/packages/store-sync/src/query-cache/common.ts +++ b/packages/store-sync/src/query-cache/common.ts @@ -1,5 +1,5 @@ import { Config, Table } from "@latticexyz/store/config/v2"; -import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type"; +import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type/internal"; import { ComparisonCondition, InCondition } from "@latticexyz/query"; export type mapTuple = { diff --git a/packages/store-sync/src/query-cache/createStorageAdapter.ts b/packages/store-sync/src/query-cache/createStorageAdapter.ts index d6b7f4e3ac..d28a313159 100644 --- a/packages/store-sync/src/query-cache/createStorageAdapter.ts +++ b/packages/store-sync/src/query-cache/createStorageAdapter.ts @@ -2,7 +2,7 @@ import { StorageAdapter } from "../common"; import { QueryCacheStore, RawTableRecord, TableRecord } from "./createStore"; import { hexToResource, resourceToLabel, spliceHex } from "@latticexyz/common"; import { Hex, concatHex, size } from "viem"; -import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser"; +import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser/internal"; import { flattenSchema } from "../flattenSchema"; import debug from "debug"; import { Tables } from "./common"; diff --git a/packages/store-sync/src/query-cache/createStore.ts b/packages/store-sync/src/query-cache/createStore.ts index a7913faf99..97fb93b50c 100644 --- a/packages/store-sync/src/query-cache/createStore.ts +++ b/packages/store-sync/src/query-cache/createStore.ts @@ -2,7 +2,7 @@ import { StoreApi, UseBoundStore, create } from "zustand"; import { Table } from "@latticexyz/store/config/v2"; import { Tables } from "./common"; import { Hex } from "viem"; -import { StaticPrimitiveType } from "@latticexyz/schema-type"; +import { StaticPrimitiveType } from "@latticexyz/schema-type/internal"; import { SchemaToPrimitives } from "@latticexyz/store"; export type RawTableRecord = { diff --git a/packages/store-sync/src/recs/common.ts b/packages/store-sync/src/recs/common.ts index f999d864eb..6b169883fe 100644 --- a/packages/store-sync/src/recs/common.ts +++ b/packages/store-sync/src/recs/common.ts @@ -1,5 +1,5 @@ import { Metadata } from "@latticexyz/recs"; -import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser"; +import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser/internal"; export type StoreComponentMetadata = Metadata & { componentName: string; diff --git a/packages/store-sync/src/recs/decodeEntity.ts b/packages/store-sync/src/recs/decodeEntity.ts index d4210de20b..63c1ff8768 100644 --- a/packages/store-sync/src/recs/decodeEntity.ts +++ b/packages/store-sync/src/recs/decodeEntity.ts @@ -1,7 +1,7 @@ import { Entity } from "@latticexyz/recs"; import { Hex, decodeAbiParameters } from "viem"; import { entityToHexKeyTuple } from "./entityToHexKeyTuple"; -import { KeySchema, SchemaToPrimitives } from "@latticexyz/protocol-parser"; +import { KeySchema, SchemaToPrimitives } from "@latticexyz/protocol-parser/internal"; export function decodeEntity( keySchema: TKeySchema, diff --git a/packages/store-sync/src/recs/encodeEntity.ts b/packages/store-sync/src/recs/encodeEntity.ts index 061a630dee..a4cd2f2f2c 100644 --- a/packages/store-sync/src/recs/encodeEntity.ts +++ b/packages/store-sync/src/recs/encodeEntity.ts @@ -1,7 +1,7 @@ import { Entity } from "@latticexyz/recs"; import { encodeAbiParameters } from "viem"; import { hexKeyTupleToEntity } from "./hexKeyTupleToEntity"; -import { KeySchema, SchemaToPrimitives } from "@latticexyz/protocol-parser"; +import { KeySchema, SchemaToPrimitives } from "@latticexyz/protocol-parser/internal"; export function encodeEntity( keySchema: TKeySchema, diff --git a/packages/store-sync/src/recs/recsStorage.ts b/packages/store-sync/src/recs/recsStorage.ts index 36849aa6f2..d594624cd6 100644 --- a/packages/store-sync/src/recs/recsStorage.ts +++ b/packages/store-sync/src/recs/recsStorage.ts @@ -4,7 +4,7 @@ import { World as RecsWorld, getComponentValue, hasComponent, removeComponent, s import { defineInternalComponents } from "./defineInternalComponents"; import { getTableEntity } from "./getTableEntity"; import { hexToResource, resourceToLabel, spliceHex } from "@latticexyz/common"; -import { decodeValueArgs } from "@latticexyz/protocol-parser"; +import { decodeValueArgs } from "@latticexyz/protocol-parser/internal"; import { Hex, size } from "viem"; import { isTableRegistrationLog } from "../isTableRegistrationLog"; import { logToTable } from "../logToTable"; diff --git a/packages/store-sync/src/recs/schemaAbiTypeToRecsType.ts b/packages/store-sync/src/recs/schemaAbiTypeToRecsType.ts index 4fe56b5f41..40727073ea 100644 --- a/packages/store-sync/src/recs/schemaAbiTypeToRecsType.ts +++ b/packages/store-sync/src/recs/schemaAbiTypeToRecsType.ts @@ -1,5 +1,5 @@ import { Type as RecsType } from "@latticexyz/recs"; -import { SchemaAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType } from "@latticexyz/schema-type/internal"; export const schemaAbiTypeToRecsType = { uint8: RecsType.Number, diff --git a/packages/store-sync/src/recs/tableToComponent.ts b/packages/store-sync/src/recs/tableToComponent.ts index 588163b6f1..2ca0280cb2 100644 --- a/packages/store-sync/src/recs/tableToComponent.ts +++ b/packages/store-sync/src/recs/tableToComponent.ts @@ -1,7 +1,7 @@ import { Component, Type, World, defineComponent } from "@latticexyz/recs"; import { StoreComponentMetadata } from "./common"; import { SchemaAbiTypeToRecsType, schemaAbiTypeToRecsType } from "./schemaAbiTypeToRecsType"; -import { SchemaAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType } from "@latticexyz/schema-type/internal"; import { Table } from "@latticexyz/store"; import { mapObject } from "@latticexyz/common/utils"; import { ResourceLabel, resourceToLabel } from "@latticexyz/common"; diff --git a/packages/store-sync/src/schemaToDefaults.ts b/packages/store-sync/src/schemaToDefaults.ts index f7658c15e0..82923ff037 100644 --- a/packages/store-sync/src/schemaToDefaults.ts +++ b/packages/store-sync/src/schemaToDefaults.ts @@ -1,5 +1,5 @@ -import { SchemaToPrimitives, ValueSchema } from "@latticexyz/protocol-parser"; -import { schemaAbiTypeToDefaultValue } from "@latticexyz/schema-type"; +import { SchemaToPrimitives, ValueSchema } from "@latticexyz/protocol-parser/internal"; +import { schemaAbiTypeToDefaultValue } from "@latticexyz/schema-type/internal"; export function schemaToDefaults(valueSchema: TSchema): SchemaToPrimitives { return Object.fromEntries( diff --git a/packages/store-sync/src/sqlite/buildColumn.ts b/packages/store-sync/src/sqlite/buildColumn.ts index 354600b146..e40a491a53 100644 --- a/packages/store-sync/src/sqlite/buildColumn.ts +++ b/packages/store-sync/src/sqlite/buildColumn.ts @@ -1,5 +1,5 @@ import { blob, integer, text } from "drizzle-orm/sqlite-core"; -import { SchemaAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType } from "@latticexyz/schema-type/internal"; import { assertExhaustive } from "@latticexyz/common/utils"; import { address, json } from "./columnTypes"; diff --git a/packages/store-sync/src/sqlite/buildTable.ts b/packages/store-sync/src/sqlite/buildTable.ts index 9178048393..eaf85b0fca 100644 --- a/packages/store-sync/src/sqlite/buildTable.ts +++ b/packages/store-sync/src/sqlite/buildTable.ts @@ -2,7 +2,7 @@ import { SQLiteColumnBuilderBase, SQLiteTableWithColumns, sqliteTable } from "dr import { buildColumn } from "./buildColumn"; import { Address } from "viem"; import { getTableName } from "./getTableName"; -import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser"; +import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser/internal"; import { snakeCase } from "change-case"; export const metaColumns = { diff --git a/packages/store-sync/src/sqlite/internalTables.ts b/packages/store-sync/src/sqlite/internalTables.ts index fe11932238..97c826eead 100644 --- a/packages/store-sync/src/sqlite/internalTables.ts +++ b/packages/store-sync/src/sqlite/internalTables.ts @@ -1,6 +1,6 @@ import { blob, integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; import { address, asHex, json } from "./columnTypes"; -import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser"; +import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser/internal"; export const chainState = sqliteTable("__chainState", { schemaVersion: integer("schema_version").notNull().primaryKey(), diff --git a/packages/store-sync/src/sqlite/sqliteStorage.ts b/packages/store-sync/src/sqlite/sqliteStorage.ts index b29cd660aa..9e7b572b6a 100644 --- a/packages/store-sync/src/sqlite/sqliteStorage.ts +++ b/packages/store-sync/src/sqlite/sqliteStorage.ts @@ -13,7 +13,7 @@ import { StorageAdapter } from "../common"; import { isTableRegistrationLog } from "../isTableRegistrationLog"; import { logToTable } from "../logToTable"; import { hexToResource, resourceToLabel, spliceHex } from "@latticexyz/common"; -import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser"; +import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser/internal"; // TODO: upgrade drizzle and use async sqlite interface for consistency diff --git a/packages/store-sync/src/tableToLog.ts b/packages/store-sync/src/tableToLog.ts index ec1670101e..adadbdfb0f 100644 --- a/packages/store-sync/src/tableToLog.ts +++ b/packages/store-sync/src/tableToLog.ts @@ -4,7 +4,7 @@ import { keySchemaToHex, valueSchemaToFieldLayoutHex, valueSchemaToHex, -} from "@latticexyz/protocol-parser"; +} from "@latticexyz/protocol-parser/internal"; import { encodeAbiParameters, parseAbiParameters } from "viem"; import { StorageAdapterLog, Table, storeTables } from "./common"; import { flattenSchema } from "./flattenSchema"; diff --git a/packages/store-sync/src/tablesWithRecordsToLogs.ts b/packages/store-sync/src/tablesWithRecordsToLogs.ts index afd37437e5..0e8dc6f07a 100644 --- a/packages/store-sync/src/tablesWithRecordsToLogs.ts +++ b/packages/store-sync/src/tablesWithRecordsToLogs.ts @@ -1,5 +1,5 @@ import { StorageAdapterLog, TableWithRecords } from "./common"; -import { encodeKey, encodeValueArgs } from "@latticexyz/protocol-parser"; +import { encodeKey, encodeValueArgs } from "@latticexyz/protocol-parser/internal"; import { tableToLog } from "./tableToLog"; /** diff --git a/packages/store-sync/src/zustand/createStorageAdapter.ts b/packages/store-sync/src/zustand/createStorageAdapter.ts index 20fea4d705..09d6f940fd 100644 --- a/packages/store-sync/src/zustand/createStorageAdapter.ts +++ b/packages/store-sync/src/zustand/createStorageAdapter.ts @@ -6,7 +6,7 @@ import { hexToResource, resourceToLabel, spliceHex } from "@latticexyz/common"; import { debug } from "./debug"; import { getId } from "./getId"; import { size } from "viem"; -import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser"; +import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser/internal"; import { flattenSchema } from "../flattenSchema"; import { isDefined } from "@latticexyz/common/utils"; diff --git a/packages/store-sync/src/zustand/createStore.ts b/packages/store-sync/src/zustand/createStore.ts index b8f11c8d67..9a6c93547a 100644 --- a/packages/store-sync/src/zustand/createStore.ts +++ b/packages/store-sync/src/zustand/createStore.ts @@ -2,7 +2,7 @@ import { SchemaToPrimitives, Table, Tables } from "@latticexyz/store"; import { StoreApi, UseBoundStore, create } from "zustand"; import { RawRecord, TableRecord } from "./common"; import { Hex } from "viem"; -import { encodeKey } from "@latticexyz/protocol-parser"; +import { encodeKey } from "@latticexyz/protocol-parser/internal"; import { flattenSchema } from "../flattenSchema"; import { getId } from "./getId"; import { SyncStep } from "../SyncStep"; diff --git a/packages/store-sync/src/zustand/logToTable.ts b/packages/store-sync/src/zustand/logToTable.ts index 703f276704..8b57d6468e 100644 --- a/packages/store-sync/src/zustand/logToTable.ts +++ b/packages/store-sync/src/zustand/logToTable.ts @@ -1,5 +1,5 @@ import { hexToResource } from "@latticexyz/common"; -import { hexToSchema, decodeValue } from "@latticexyz/protocol-parser"; +import { hexToSchema, decodeValue } from "@latticexyz/protocol-parser/internal"; import { concatHex, decodeAbiParameters, parseAbiParameters } from "viem"; import { StorageAdapterLog, schemasTable } from "../common"; import { Table } from "@latticexyz/store"; diff --git a/packages/store/ts/codegen/renderTable.ts b/packages/store/ts/codegen/renderTable.ts index b67fc87650..0aa30588c2 100644 --- a/packages/store/ts/codegen/renderTable.ts +++ b/packages/store/ts/codegen/renderTable.ts @@ -14,7 +14,7 @@ import { renderEncodeFieldSingle, renderFieldMethods } from "./field"; import { renderDeleteRecordMethods, renderRecordData, renderRecordMethods } from "./record"; import { renderFieldLayout } from "./renderFieldLayout"; import { RenderTableOptions } from "./types"; -import { KeySchema, ValueSchema, keySchemaToHex, valueSchemaToHex } from "@latticexyz/protocol-parser"; +import { KeySchema, ValueSchema, keySchemaToHex, valueSchemaToHex } from "@latticexyz/protocol-parser/internal"; /** * Renders Solidity code for a MUD table library, using the specified options diff --git a/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts b/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts index 1e1518eaec..2d0553372b 100644 --- a/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts +++ b/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts @@ -1,5 +1,5 @@ import { renderedSolidityHeader } from "@latticexyz/common/codegen"; -import { staticAbiTypeToByteLength, staticAbiTypes } from "@latticexyz/schema-type"; +import { staticAbiTypeToByteLength, staticAbiTypes } from "@latticexyz/schema-type/internal"; import { renderTightCoderDecode } from "./renderFunctions"; /** diff --git a/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts b/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts index 27d894a2d4..f750cff4f6 100644 --- a/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts +++ b/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts @@ -1,5 +1,5 @@ import { renderedSolidityHeader } from "@latticexyz/common/codegen"; -import { staticAbiTypeToByteLength, staticAbiTypes } from "@latticexyz/schema-type"; +import { staticAbiTypeToByteLength, staticAbiTypes } from "@latticexyz/schema-type/internal"; import { renderTightCoderEncode } from "./renderFunctions"; /** diff --git a/packages/store/ts/codegen/tightcoder/renderTightCoderAutoTest.ts b/packages/store/ts/codegen/tightcoder/renderTightCoderAutoTest.ts index 77ee228488..a228ac37c0 100644 --- a/packages/store/ts/codegen/tightcoder/renderTightCoderAutoTest.ts +++ b/packages/store/ts/codegen/tightcoder/renderTightCoderAutoTest.ts @@ -1,5 +1,5 @@ import { renderedSolidityHeader } from "@latticexyz/common/codegen"; -import { staticAbiTypes } from "@latticexyz/schema-type"; +import { staticAbiTypes } from "@latticexyz/schema-type/internal"; export function renderTightCoderAutoTestFunction({ typeId }: { typeId: string }) { return ` diff --git a/packages/store/ts/common.ts b/packages/store/ts/common.ts index 5a9d1ebeb9..2348763081 100644 --- a/packages/store/ts/common.ts +++ b/packages/store/ts/common.ts @@ -1,4 +1,4 @@ -import { SchemaAbiType, SchemaAbiTypeToPrimitiveType, StaticAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType, SchemaAbiTypeToPrimitiveType, StaticAbiType } from "@latticexyz/schema-type/internal"; import { FieldData, FullSchemaConfig, StoreConfig } from "./config"; import { Hex } from "viem"; diff --git a/packages/store/ts/config/experimental/resolveConfig.ts b/packages/store/ts/config/experimental/resolveConfig.ts index 0d03e36884..221377c5df 100644 --- a/packages/store/ts/config/experimental/resolveConfig.ts +++ b/packages/store/ts/config/experimental/resolveConfig.ts @@ -3,7 +3,7 @@ import { StoreConfig, TableConfig, UserTypesConfig } from "../storeConfig"; import { UserType } from "@latticexyz/common/codegen"; import { mapObject } from "@latticexyz/common/utils"; import { resourceToHex } from "@latticexyz/common"; -import { SchemaAbiType } from "@latticexyz/schema-type"; +import { SchemaAbiType } from "@latticexyz/schema-type/internal"; /** * @internal Internal only diff --git a/packages/store/ts/config/storeConfig.ts b/packages/store/ts/config/storeConfig.ts index 382df6b8a0..9f73ebf54a 100644 --- a/packages/store/ts/config/storeConfig.ts +++ b/packages/store/ts/config/storeConfig.ts @@ -23,7 +23,7 @@ import { } from "@latticexyz/config/library"; import { DEFAULTS, PATH_DEFAULTS, TABLE_DEFAULTS } from "./defaults"; import { UserType } from "@latticexyz/common/codegen"; -import { SchemaAbiType, isSchemaAbiType, schemaAbiTypes } from "@latticexyz/schema-type"; +import { SchemaAbiType, isSchemaAbiType, schemaAbiTypes } from "@latticexyz/schema-type/internal"; const zTableName = zObjectName; const zKeyName = zValueName; diff --git a/packages/store/ts/config/v2/scope.ts b/packages/store/ts/config/v2/scope.ts index 180c3209e0..7343ee6a36 100644 --- a/packages/store/ts/config/v2/scope.ts +++ b/packages/store/ts/config/v2/scope.ts @@ -1,6 +1,6 @@ import { Dict, evaluate } from "@arktype/util"; import { SchemaInput } from "./schema"; -import { StaticAbiType, schemaAbiTypes } from "@latticexyz/schema-type"; +import { StaticAbiType, schemaAbiTypes } from "@latticexyz/schema-type/internal"; import { AbiType } from "./output"; export const EmptyScope = { types: {} } as const satisfies ScopeOptions; diff --git a/packages/store/ts/config/v2/store.ts b/packages/store/ts/config/v2/store.ts index 33508661fe..7edb55e764 100644 --- a/packages/store/ts/config/v2/store.ts +++ b/packages/store/ts/config/v2/store.ts @@ -3,7 +3,7 @@ import { get, isObject } from "./generics"; import { SchemaInput } from "./schema"; import { TableInput, resolveTableConfig, validateTableConfig } from "./table"; import { AbiTypeScope, extendScope } from "./scope"; -import { isSchemaAbiType } from "@latticexyz/schema-type"; +import { isSchemaAbiType } from "@latticexyz/schema-type/internal"; import { UserTypes, Enums, CodegenOptions } from "./output"; import { isTableShorthandInput, resolveTableShorthand, validateTableShorthand } from "./tableShorthand"; import { CODEGEN_DEFAULTS, CONFIG_DEFAULTS } from "./defaults"; diff --git a/packages/store/ts/config/v2/tableFull.ts b/packages/store/ts/config/v2/tableFull.ts index 7ae5ddf248..46216e40e7 100644 --- a/packages/store/ts/config/v2/tableFull.ts +++ b/packages/store/ts/config/v2/tableFull.ts @@ -1,5 +1,5 @@ import { conform, evaluate } from "@arktype/util"; -import { isStaticAbiType } from "@latticexyz/schema-type"; +import { isStaticAbiType } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { get, hasOwnKey } from "./generics"; import { SchemaInput, isSchemaInput, resolveSchema } from "./schema"; diff --git a/packages/store/ts/config/v2/tableShorthand.ts b/packages/store/ts/config/v2/tableShorthand.ts index 405e71096e..e6b45d135e 100644 --- a/packages/store/ts/config/v2/tableShorthand.ts +++ b/packages/store/ts/config/v2/tableShorthand.ts @@ -1,5 +1,5 @@ import { ErrorMessage, evaluate } from "@arktype/util"; -import { isStaticAbiType } from "@latticexyz/schema-type"; +import { isStaticAbiType } from "@latticexyz/schema-type/internal"; import { hasOwnKey } from "./generics"; import { SchemaInput, isSchemaInput } from "./schema"; import { AbiTypeScope, getStaticAbiTypeKeys } from "./scope";