From 7129a16057a7fcc7195015a916bdf74e0809f3a2 Mon Sep 17 00:00:00 2001 From: David Blass Date: Thu, 11 Jul 2024 08:12:27 -0400 Subject: [PATCH] fix: preserve JsDoc on defineWorld output, bump @arktype/util (#2815) Co-authored-by: Kevin Ingersoll --- .changeset/good-rice-bathe.md | 8 +++++ .changeset/ninety-mirrors-pretend.md | 5 +++ package.json | 2 -- packages/common/src/type-utils/evaluate.ts | 2 -- packages/common/src/type-utils/index.ts | 2 -- packages/common/src/type-utils/satisfy.ts | 1 - packages/config/package.json | 1 + packages/config/src/common.ts | 2 +- packages/query/package.json | 1 + packages/query/src/api.ts | 2 +- packages/store/package.json | 3 +- packages/store/ts/config/v2/input.ts | 4 +-- packages/store/ts/config/v2/output.ts | 4 +-- packages/store/ts/config/v2/schema.ts | 4 +-- packages/store/ts/config/v2/scope.ts | 6 ++-- packages/store/ts/config/v2/store.ts | 6 ++-- packages/store/ts/config/v2/table.ts | 4 +-- packages/store/ts/config/v2/tables.ts | 4 +-- packages/world/package.json | 3 +- packages/world/ts/config/v2/input.ts | 4 +-- packages/world/ts/config/v2/world.ts | 14 ++++---- pnpm-lock.yaml | 41 +++++++++++----------- 22 files changed, 68 insertions(+), 55 deletions(-) create mode 100644 .changeset/good-rice-bathe.md create mode 100644 .changeset/ninety-mirrors-pretend.md delete mode 100644 packages/common/src/type-utils/evaluate.ts delete mode 100644 packages/common/src/type-utils/satisfy.ts diff --git a/.changeset/good-rice-bathe.md b/.changeset/good-rice-bathe.md new file mode 100644 index 0000000000..1016ac7f1b --- /dev/null +++ b/.changeset/good-rice-bathe.md @@ -0,0 +1,8 @@ +--- +"@latticexyz/config": patch +"@latticexyz/query": patch +"@latticexyz/store": patch +"@latticexyz/world": patch +--- + +Bumped `@arktype/util` and moved `evaluate`/`satisfy` usages to its `show`/`satisfy` helpers. diff --git a/.changeset/ninety-mirrors-pretend.md b/.changeset/ninety-mirrors-pretend.md new file mode 100644 index 0000000000..c19441bf20 --- /dev/null +++ b/.changeset/ninety-mirrors-pretend.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/common": patch +--- + +Removed `evaluate` and `satisfy` type utils in favor of `show` and `satisfy` from `@arktype/util`. diff --git a/package.json b/package.json index b6350d9599..dc0100ac15 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,6 @@ "package.json": "pnpm sort-package-json" }, "devDependencies": { - "@arktype/attest": "0.7.5", - "@arktype/util": "0.0.43", "@changesets/cli": "^2.26.1", "@types/node": "^18.15.11", "@typescript-eslint/eslint-plugin": "7.1.1", diff --git a/packages/common/src/type-utils/evaluate.ts b/packages/common/src/type-utils/evaluate.ts deleted file mode 100644 index 14f9b55283..0000000000 --- a/packages/common/src/type-utils/evaluate.ts +++ /dev/null @@ -1,2 +0,0 @@ -// https://github.com/arktypeio/arktype/blob/93e79fa3d28567b7547e8e2df9a84e3c5b86e8e1/src/utils/generics.ts#L23 -export type evaluate = { [k in keyof t]: t[k] } & unknown; diff --git a/packages/common/src/type-utils/index.ts b/packages/common/src/type-utils/index.ts index 1cd21a40c7..866ee2904c 100644 --- a/packages/common/src/type-utils/index.ts +++ b/packages/common/src/type-utils/index.ts @@ -1,4 +1,2 @@ export * from "./abi"; export * from "./common"; -export * from "./evaluate"; -export * from "./satisfy"; diff --git a/packages/common/src/type-utils/satisfy.ts b/packages/common/src/type-utils/satisfy.ts deleted file mode 100644 index 61f7863418..0000000000 --- a/packages/common/src/type-utils/satisfy.ts +++ /dev/null @@ -1 +0,0 @@ -export type satisfy = t; diff --git a/packages/config/package.json b/packages/config/package.json index 804f98e76d..d6b98f3d98 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -48,6 +48,7 @@ "test:ci": "pnpm run test" }, "dependencies": { + "@arktype/util": "0.0.40", "@latticexyz/common": "workspace:*", "@latticexyz/schema-type": "workspace:*", "esbuild": "^0.17.15", diff --git a/packages/config/src/common.ts b/packages/config/src/common.ts index 037a910698..e08c34634a 100644 --- a/packages/config/src/common.ts +++ b/packages/config/src/common.ts @@ -1,7 +1,7 @@ import { Hex } from "viem"; import { DynamicAbiType, StaticAbiType } from "@latticexyz/schema-type/internal"; import { ResourceType } from "@latticexyz/common"; -import { satisfy } from "@latticexyz/common/type-utils"; +import { satisfy } from "@arktype/util"; /** * Common output types of a MUD config. We use these types as inputs for libraries. diff --git a/packages/query/package.json b/packages/query/package.json index 0593440c54..5855652bec 100644 --- a/packages/query/package.json +++ b/packages/query/package.json @@ -34,6 +34,7 @@ "test:ci": "pnpm run test" }, "dependencies": { + "@arktype/util": "0.0.40", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", "@latticexyz/schema-type": "workspace:*", diff --git a/packages/query/src/api.ts b/packages/query/src/api.ts index 48479801cd..27108ff30a 100644 --- a/packages/query/src/api.ts +++ b/packages/query/src/api.ts @@ -1,6 +1,6 @@ import { Hex } from "viem"; +import { satisfy } from "@arktype/util"; import { StaticPrimitiveType, DynamicPrimitiveType, SchemaAbiType } from "@latticexyz/schema-type/internal"; -import { satisfy } from "@latticexyz/common/type-utils"; import { SchemaToPrimitives } from "@latticexyz/store/internal"; import { Table } from "@latticexyz/config"; diff --git a/packages/store/package.json b/packages/store/package.json index a787d9e127..6d0df9bd52 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -67,7 +67,7 @@ "test:ci": "pnpm run test" }, "dependencies": { - "@arktype/util": "0.0.29", + "@arktype/util": "0.0.40", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", "@latticexyz/protocol-parser": "workspace:*", @@ -78,6 +78,7 @@ "zod": "^3.22.2" }, "devDependencies": { + "@arktype/attest": "0.7.5", "@latticexyz/abi-ts": "workspace:*", "@latticexyz/gas-report": "workspace:*", "@types/ejs": "^3.1.1", diff --git a/packages/store/ts/config/v2/input.ts b/packages/store/ts/config/v2/input.ts index dde3083d04..7f15491ca1 100644 --- a/packages/store/ts/config/v2/input.ts +++ b/packages/store/ts/config/v2/input.ts @@ -1,7 +1,7 @@ import { Hex } from "viem"; import { Codegen, TableCodegen, TableDeploy, UserTypes } from "./output"; import { Scope } from "./scope"; -import { evaluate } from "@arktype/util"; +import { show } from "@arktype/util"; export type EnumsInput = { readonly [enumName: string]: readonly [string, ...string[]]; @@ -58,4 +58,4 @@ export type TablesWithShorthandsInput = { readonly [label: string]: TableInput | TableShorthandInput; }; -export type StoreWithShorthandsInput = evaluate & { tables: TablesWithShorthandsInput }>; +export type StoreWithShorthandsInput = show & { tables: TablesWithShorthandsInput }>; diff --git a/packages/store/ts/config/v2/output.ts b/packages/store/ts/config/v2/output.ts index 91ea668e84..ddc4c63e45 100644 --- a/packages/store/ts/config/v2/output.ts +++ b/packages/store/ts/config/v2/output.ts @@ -1,4 +1,4 @@ -import { evaluate } from "@arktype/util"; +import { show } from "@arktype/util"; import { AbiType, Schema, Table as BaseTable } from "@latticexyz/config"; import { EnumsInput } from "./input"; @@ -33,7 +33,7 @@ export type TableDeploy = { readonly disabled: boolean; }; -export type Table = evaluate< +export type Table = show< BaseTable & { readonly codegen: TableCodegen; readonly deploy: TableDeploy; diff --git a/packages/store/ts/config/v2/schema.ts b/packages/store/ts/config/v2/schema.ts index 099d2fd820..e053a67b9c 100644 --- a/packages/store/ts/config/v2/schema.ts +++ b/packages/store/ts/config/v2/schema.ts @@ -1,4 +1,4 @@ -import { conform, evaluate } from "@arktype/util"; +import { conform, show } from "@arktype/util"; import { AbiTypeScope, Scope } from "./scope"; import { hasOwnKey, isObject } from "./generics"; import { SchemaInput } from "./input"; @@ -27,7 +27,7 @@ export function validateSchema( } } -export type resolveSchema = evaluate<{ +export type resolveSchema = show<{ readonly [key in keyof schema]: { /** the Solidity primitive ABI type */ readonly type: schema[key] extends FixedArrayAbiType diff --git a/packages/store/ts/config/v2/scope.ts b/packages/store/ts/config/v2/scope.ts index a5f70e6f5d..7c033f23cb 100644 --- a/packages/store/ts/config/v2/scope.ts +++ b/packages/store/ts/config/v2/scope.ts @@ -1,4 +1,4 @@ -import { Dict, evaluate } from "@arktype/util"; +import { Dict, show } from "@arktype/util"; import { SchemaInput } from "./input"; import { StaticAbiType, schemaAbiTypes } from "@latticexyz/schema-type/internal"; import { AbiType } from "./output"; @@ -24,8 +24,8 @@ export type getStaticAbiTypeKeys< [key in keyof schema]: scope["types"] extends { [_ in schema[key]]: StaticAbiType } ? key : never; }[keyof schema]; -export type extendScope> = evaluate< - ScopeOptions> +export type extendScope> = show< + ScopeOptions> >; export function extendScope>( diff --git a/packages/store/ts/config/v2/store.ts b/packages/store/ts/config/v2/store.ts index 1337a38286..7f7fe8cff8 100644 --- a/packages/store/ts/config/v2/store.ts +++ b/packages/store/ts/config/v2/store.ts @@ -1,4 +1,4 @@ -import { ErrorMessage, evaluate, flatMorph, narrow } from "@arktype/util"; +import { ErrorMessage, show, flatMorph, narrow } from "@arktype/util"; import { get, hasOwnKey, mergeIfUndefined } from "./generics"; import { UserTypes } from "./output"; import { CONFIG_DEFAULTS } from "./defaults"; @@ -59,8 +59,8 @@ export type resolveStore = { > : {}; readonly userTypes: "userTypes" extends keyof store ? store["userTypes"] : {}; - readonly enums: "enums" extends keyof store ? evaluate> : {}; - readonly enumValues: "enums" extends keyof store ? evaluate> : {}; + readonly enums: "enums" extends keyof store ? show> : {}; + readonly enumValues: "enums" extends keyof store ? show> : {}; readonly namespace: "namespace" extends keyof store ? store["namespace"] : CONFIG_DEFAULTS["namespace"]; readonly codegen: "codegen" extends keyof store ? resolveCodegen : resolveCodegen<{}>; }; diff --git a/packages/store/ts/config/v2/table.ts b/packages/store/ts/config/v2/table.ts index e07ef4863d..e44bd7c918 100644 --- a/packages/store/ts/config/v2/table.ts +++ b/packages/store/ts/config/v2/table.ts @@ -1,4 +1,4 @@ -import { ErrorMessage, conform, evaluate, narrow, requiredKeyOf } from "@arktype/util"; +import { ErrorMessage, conform, show, narrow, requiredKeyOf } from "@arktype/util"; import { isStaticAbiType } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; import { get, hasOwnKey, mergeIfUndefined } from "./generics"; @@ -101,7 +101,7 @@ export function validateTable( } } -export type resolveTableCodegen = evaluate<{ +export type resolveTableCodegen = show<{ [key in keyof TableCodegen]-?: key extends keyof input["codegen"] ? undefined extends input["codegen"][key] ? key extends "dataStruct" diff --git a/packages/store/ts/config/v2/tables.ts b/packages/store/ts/config/v2/tables.ts index bd54bd98a7..4d76aecbd9 100644 --- a/packages/store/ts/config/v2/tables.ts +++ b/packages/store/ts/config/v2/tables.ts @@ -1,4 +1,4 @@ -import { ErrorMessage, evaluate } from "@arktype/util"; +import { ErrorMessage, show } from "@arktype/util"; import { isObject, mergeIfUndefined } from "./generics"; import { TablesInput } from "./input"; import { Scope, AbiTypeScope } from "./scope"; @@ -23,7 +23,7 @@ export function validateTables( throw new Error(`Expected store config, received ${JSON.stringify(input)}`); } -export type resolveTables = evaluate<{ +export type resolveTables = show<{ readonly [label in keyof tables]: resolveTable, scope>; }>; diff --git a/packages/world/package.json b/packages/world/package.json index dc8a4885a5..0b7ce19f61 100644 --- a/packages/world/package.json +++ b/packages/world/package.json @@ -63,7 +63,7 @@ "test:ci": "pnpm run test" }, "dependencies": { - "@arktype/util": "0.0.29", + "@arktype/util": "0.0.40", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", "@latticexyz/protocol-parser": "workspace:*", @@ -75,6 +75,7 @@ "zod": "^3.22.2" }, "devDependencies": { + "@arktype/attest": "0.7.5", "@latticexyz/abi-ts": "workspace:*", "@latticexyz/gas-report": "workspace:*", "@types/ejs": "^3.1.1", diff --git a/packages/world/ts/config/v2/input.ts b/packages/world/ts/config/v2/input.ts index 8879265d05..2967703ded 100644 --- a/packages/world/ts/config/v2/input.ts +++ b/packages/world/ts/config/v2/input.ts @@ -1,4 +1,4 @@ -import { evaluate } from "@arktype/util"; +import { show } from "@arktype/util"; import { StoreInput, StoreWithShorthandsInput } from "@latticexyz/store/config/v2"; import { DynamicResolution, ValueWithType } from "./dynamicResolution"; @@ -79,7 +79,7 @@ export type CodegenInput = { worldImportPath?: string; }; -export type WorldInput = evaluate< +export type WorldInput = show< StoreInput & { namespaces?: NamespacesInput; /** diff --git a/packages/world/ts/config/v2/world.ts b/packages/world/ts/config/v2/world.ts index a04d90ed42..5fc6257b4f 100644 --- a/packages/world/ts/config/v2/world.ts +++ b/packages/world/ts/config/v2/world.ts @@ -1,4 +1,4 @@ -import { ErrorMessage, conform, evaluate, narrow } from "@arktype/util"; +import { ErrorMessage, conform, narrow, type withJsDoc } from "@arktype/util"; import { UserTypes, extendedScope, @@ -19,6 +19,7 @@ import { resolveSystems } from "./systems"; import { resolveNamespacedTables, validateNamespaces } from "./namespaces"; import { resolveCodegen } from "./codegen"; import { resolveDeploy } from "./deploy"; +import type { World } from "./output.js"; export type validateWorld = { readonly [key in keyof world]: key extends "tables" @@ -44,7 +45,7 @@ export function validateWorld(world: unknown): asserts world is WorldInput { } } -export type resolveWorld = evaluate< +export type resolveWorld = withJsDoc< resolveStore & mergeIfUndefined< { tables: resolveNamespacedTables } & Omit< @@ -60,7 +61,8 @@ export type resolveWorld = evaluate< "namespaces" | keyof Store >, CONFIG_DEFAULTS - > + >, + World >; export function resolveWorld(world: world): resolveWorld { @@ -99,7 +101,7 @@ export function resolveWorld(world: world): reso ) as never; } -export function defineWorld(world: validateWorld): resolveWorld { - validateWorld(world); - return resolveWorld(world) as never; +export function defineWorld(input: validateWorld): resolveWorld { + validateWorld(input); + return resolveWorld(input) as never; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99d0e672ae..38b03accc0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,12 +8,6 @@ importers: .: devDependencies: - '@arktype/attest': - specifier: 0.7.5 - version: 0.7.5(typescript@5.4.2) - '@arktype/util': - specifier: 0.0.43 - version: 0.0.43 '@changesets/cli': specifier: ^2.26.1 version: 2.26.1 @@ -321,6 +315,9 @@ importers: packages/config: dependencies: + '@arktype/util': + specifier: 0.0.40 + version: 0.0.40 '@latticexyz/common': specifier: workspace:* version: link:../common @@ -555,6 +552,9 @@ importers: packages/query: dependencies: + '@arktype/util': + specifier: 0.0.40 + version: 0.0.40 '@latticexyz/common': specifier: workspace:* version: link:../common @@ -711,8 +711,8 @@ importers: packages/store: dependencies: '@arktype/util': - specifier: 0.0.29 - version: 0.0.29 + specifier: 0.0.40 + version: 0.0.40 '@latticexyz/common': specifier: workspace:* version: link:../common @@ -738,6 +738,9 @@ importers: specifier: ^3.22.2 version: 3.23.7 devDependencies: + '@arktype/attest': + specifier: 0.7.5 + version: 0.7.5(typescript@5.4.2) '@latticexyz/abi-ts': specifier: workspace:* version: link:../abi-ts @@ -1009,8 +1012,8 @@ importers: packages/world: dependencies: '@arktype/util': - specifier: 0.0.29 - version: 0.0.29 + specifier: 0.0.40 + version: 0.0.40 '@latticexyz/common': specifier: workspace:* version: link:../common @@ -1039,6 +1042,9 @@ importers: specifier: ^3.22.2 version: 3.23.7 devDependencies: + '@arktype/attest': + specifier: 0.7.5 + version: 0.7.5(typescript@5.4.2) '@latticexyz/abi-ts': specifier: workspace:* version: link:../abi-ts @@ -1202,18 +1208,15 @@ packages: '@arktype/schema@0.1.2': resolution: {integrity: sha512-ggvxs5P0toqd/4/XK76URQrtyOYpbYcLhirEZeTso6FxkloPa0lT+whPg7DNQj5qi2OQXLUHBYKMx9DOb13ViQ==} - '@arktype/util@0.0.29': - resolution: {integrity: sha512-fDTBSVzxLj9k1ZjinkawmaQdcXFKMBVK8c+vqMPxwoa94mPMZxBo84yQcqyFVcIcWIkg6qQQmH1ozyT4nqFT/g==} - '@arktype/util@0.0.38': resolution: {integrity: sha512-IvYMGnkUASJllRk3mdBVgckomKx2LNsDTrWCxz04EBK1OuU+4fJ/smSjxgZVWfopNXZds9sHNxZgTJOIw7GvJw==} + '@arktype/util@0.0.40': + resolution: {integrity: sha512-dwC3xZh9Bz6LWSJq71AUoh06zB0qM65N4zS/NNogbumhbO55yot7yqDlv0qeBMNOWXj/gX7l7l58v0EqEaXN2w==} + '@arktype/util@0.0.41': resolution: {integrity: sha512-0YURzJ42v+lhlP1t5Dj90YezETRTCdFU0oM4xMVpYsmPx/DHJzr9n7AX1QPAlYWH4wY7hYY3gwai3O+8VntPgw==} - '@arktype/util@0.0.43': - resolution: {integrity: sha512-tVrvIoghAI/OY6Oc8wo8dpgiZc/a+C8M7NnpSDvfkagAasW9CzLtEbybP1xAALf3A6y5cuJOV6cCcIi9NKQRzA==} - '@aws-crypto/ie11-detection@3.0.0': resolution: {integrity: sha512-341lBBkiY1DfDNKai/wXM3aujNBkXR7tq1URPQDL9wi3AUbI80NR74uF1TXHMm7po1AcnFk8iu2S2IeU/+/A+Q==} @@ -6911,13 +6914,11 @@ snapshots: dependencies: '@arktype/util': 0.0.38 - '@arktype/util@0.0.29': {} - '@arktype/util@0.0.38': {} - '@arktype/util@0.0.41': {} + '@arktype/util@0.0.40': {} - '@arktype/util@0.0.43': {} + '@arktype/util@0.0.41': {} '@aws-crypto/ie11-detection@3.0.0': dependencies: