Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preserve JsDoc on defineWorld output, bump @arktype/util #2815

Merged
merged 9 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/good-rice-bathe.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions .changeset/ninety-mirrors-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/common": patch
---

Removed `evaluate` and `satisfy` type utils in favor of `show` and `satisfy` from `@arktype/util`.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions packages/common/src/type-utils/evaluate.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/common/src/type-utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from "./abi";
export * from "./common";
export * from "./evaluate";
export * from "./satisfy";
1 change: 0 additions & 1 deletion packages/common/src/type-utils/satisfy.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/common.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions packages/query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/query/src/api.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
3 changes: 2 additions & 1 deletion packages/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/store/ts/config/v2/input.ts
Original file line number Diff line number Diff line change
@@ -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[]];
Expand Down Expand Up @@ -58,4 +58,4 @@ export type TablesWithShorthandsInput = {
readonly [label: string]: TableInput | TableShorthandInput;
};

export type StoreWithShorthandsInput = evaluate<Omit<StoreInput, "tables"> & { tables: TablesWithShorthandsInput }>;
export type StoreWithShorthandsInput = show<Omit<StoreInput, "tables"> & { tables: TablesWithShorthandsInput }>;
4 changes: 2 additions & 2 deletions packages/store/ts/config/v2/output.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/store/ts/config/v2/schema.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -27,7 +27,7 @@ export function validateSchema<scope extends Scope = AbiTypeScope>(
}
}

export type resolveSchema<schema, scope extends Scope> = evaluate<{
export type resolveSchema<schema, scope extends Scope> = show<{
readonly [key in keyof schema]: {
/** the Solidity primitive ABI type */
readonly type: schema[key] extends FixedArrayAbiType
Expand Down
6 changes: 3 additions & 3 deletions packages/store/ts/config/v2/scope.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>> = evaluate<
ScopeOptions<evaluate<scope["types"] & additionalTypes>>
export type extendScope<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>> = show<
ScopeOptions<show<scope["types"] & additionalTypes>>
>;

export function extendScope<scope extends ScopeOptions, additionalTypes extends Dict<string, AbiType>>(
Expand Down
6 changes: 3 additions & 3 deletions packages/store/ts/config/v2/store.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -59,8 +59,8 @@ export type resolveStore<store> = {
>
: {};
readonly userTypes: "userTypes" extends keyof store ? store["userTypes"] : {};
readonly enums: "enums" extends keyof store ? evaluate<resolveEnums<store["enums"]>> : {};
readonly enumValues: "enums" extends keyof store ? evaluate<mapEnums<store["enums"]>> : {};
readonly enums: "enums" extends keyof store ? show<resolveEnums<store["enums"]>> : {};
readonly enumValues: "enums" extends keyof store ? show<mapEnums<store["enums"]>> : {};
readonly namespace: "namespace" extends keyof store ? store["namespace"] : CONFIG_DEFAULTS["namespace"];
readonly codegen: "codegen" extends keyof store ? resolveCodegen<store["codegen"]> : resolveCodegen<{}>;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/store/ts/config/v2/table.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -101,7 +101,7 @@ export function validateTable<input, scope extends Scope = AbiTypeScope>(
}
}

export type resolveTableCodegen<input extends TableInput> = evaluate<{
export type resolveTableCodegen<input extends TableInput> = show<{
[key in keyof TableCodegen]-?: key extends keyof input["codegen"]
? undefined extends input["codegen"][key]
? key extends "dataStruct"
Expand Down
4 changes: 2 additions & 2 deletions packages/store/ts/config/v2/tables.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -23,7 +23,7 @@ export function validateTables<scope extends Scope = AbiTypeScope>(
throw new Error(`Expected store config, received ${JSON.stringify(input)}`);
}

export type resolveTables<tables, scope extends Scope = AbiTypeScope> = evaluate<{
export type resolveTables<tables, scope extends Scope = AbiTypeScope> = show<{
readonly [label in keyof tables]: resolveTable<mergeIfUndefined<tables[label], { name: label }>, scope>;
}>;

Expand Down
3 changes: 2 additions & 1 deletion packages/world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/world/ts/config/v2/input.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -79,7 +79,7 @@ export type CodegenInput = {
worldImportPath?: string;
};

export type WorldInput = evaluate<
export type WorldInput = show<
StoreInput & {
namespaces?: NamespacesInput;
/**
Expand Down
14 changes: 8 additions & 6 deletions packages/world/ts/config/v2/world.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ErrorMessage, conform, evaluate, narrow } from "@arktype/util";
import { ErrorMessage, conform, narrow, type withJsDoc } from "@arktype/util";
import {
UserTypes,
extendedScope,
Expand All @@ -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<world> = {
readonly [key in keyof world]: key extends "tables"
Expand All @@ -44,7 +45,7 @@ export function validateWorld(world: unknown): asserts world is WorldInput {
}
}

export type resolveWorld<world> = evaluate<
export type resolveWorld<world> = withJsDoc<
resolveStore<world> &
mergeIfUndefined<
{ tables: resolveNamespacedTables<world> } & Omit<
Expand All @@ -60,7 +61,8 @@ export type resolveWorld<world> = evaluate<
"namespaces" | keyof Store
>,
CONFIG_DEFAULTS
>
>,
World
>;

export function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world> {
Expand Down Expand Up @@ -99,7 +101,7 @@ export function resolveWorld<const world extends WorldInput>(world: world): reso
) as never;
}

export function defineWorld<const world>(world: validateWorld<world>): resolveWorld<world> {
validateWorld(world);
return resolveWorld(world) as never;
export function defineWorld<const input>(input: validateWorld<input>): resolveWorld<input> {
validateWorld(input);
return resolveWorld(input) as never;
}
41 changes: 21 additions & 20 deletions pnpm-lock.yaml

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

Loading