Skip to content

Commit bde8bd6

Browse files
authored
fix(world): disable namespaces in defineWorld (latticexyz#2498)
1 parent c9ee5e4 commit bde8bd6

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

packages/world/ts/config/v2/world.test.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from "vitest";
2-
import { defineWorld, defineWorldWithoutNamespaces } from "./world";
2+
import { defineWorld } from "./world";
33
import { attest } from "@arktype/attest";
44
import { resourceToHex } from "@latticexyz/common";
55
import {
@@ -14,6 +14,7 @@ const CODEGEN_DEFAULTS = { ...STORE_CODEGEN_DEFAULTS, ...WORLD_CODEGEN_DEFAULTS
1414
describe("defineWorld", () => {
1515
it("should resolve namespaced tables", () => {
1616
const config = defineWorld({
17+
// @ts-expect-error TODO: remove once namespaces support ships
1718
namespaces: {
1819
ExampleNamespace: {
1920
tables: {
@@ -68,6 +69,7 @@ describe("defineWorld", () => {
6869

6970
it("should resolve namespaced table config with user types and enums", () => {
7071
const config = defineWorld({
72+
// @ts-expect-error TODO: remove once namespaces support ships
7173
namespaces: {
7274
ExampleNamespace: {
7375
tables: {
@@ -134,6 +136,7 @@ describe("defineWorld", () => {
134136

135137
it("should extend the output World type", () => {
136138
const config = defineWorld({
139+
// @ts-expect-error TODO: remove once namespaces support ships
137140
namespaces: {
138141
ExampleNamespace: {
139142
tables: {
@@ -163,6 +166,7 @@ describe("defineWorld", () => {
163166
it("should not use the global namespace for namespaced tables", () => {
164167
const config = defineWorld({
165168
namespace: "namespace",
169+
// @ts-expect-error TODO: remove once namespaces support ships
166170
namespaces: {
167171
AnotherOne: {
168172
tables: {
@@ -677,16 +681,16 @@ describe("defineWorld", () => {
677681
).throwsAndHasTypeError("Overrides of `name` and `namespace` are not allowed for tables in a store config");
678682
});
679683

680-
it("should throw if name is overridden in namespaced tables", () => {
684+
it.skip("should throw if name is overridden in namespaced tables", () => {
681685
attest(() =>
682686
defineWorld({
687+
// @ts-expect-error TODO: remove once namespaces support ships
683688
namespaces: {
684689
MyNamespace: {
685690
tables: {
686691
Example: {
687692
schema: { id: "address" },
688693
key: ["id"],
689-
// @ts-expect-error "Overrides of `name` and `namespace` are not allowed for tables in a store config"
690694
name: "NotAllowed",
691695
},
692696
},
@@ -696,16 +700,16 @@ describe("defineWorld", () => {
696700
).throwsAndHasTypeError("Overrides of `name` and `namespace` are not allowed for tables in a store config");
697701
});
698702

699-
it("should throw if namespace is overridden in namespaced tables", () => {
703+
it.skip("should throw if namespace is overridden in namespaced tables", () => {
700704
attest(() =>
701705
defineWorld({
706+
// @ts-expect-error TODO: remove once namespaces support ships
702707
namespaces: {
703708
MyNamespace: {
704709
tables: {
705710
Example: {
706711
schema: { id: "address" },
707712
key: ["id"],
708-
// @ts-expect-error "Overrides of `name` and `namespace` are not allowed for tables in a store config"
709713
namespace: "NotAllowed",
710714
},
711715
},
@@ -714,15 +718,13 @@ describe("defineWorld", () => {
714718
}),
715719
).throwsAndHasTypeError("Overrides of `name` and `namespace` are not allowed for tables in a store config");
716720
});
717-
});
718721

719-
describe("defineWorldWithoutNamespaces", () => {
720-
it("should throw if namespaces are defined", () => {
722+
it("should throw if namespaces are defined (TODO: remove once namespaces support ships)", () => {
721723
attest(() =>
722-
defineWorldWithoutNamespaces({
723-
// @ts-expect-error Namespaces will be enabled soon
724+
defineWorld({
725+
// @ts-expect-error TODO: remove once namespaces support ships
724726
namespaces: {},
725727
}),
726-
).type.errors("Namespaces will be enabled soon");
728+
).type.errors("Namespaces config will be enabled soon.");
727729
});
728730
});

packages/world/ts/config/v2/world.ts

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { conform, evaluate, narrow } from "@arktype/util";
1+
import { ErrorMessage, conform, evaluate, narrow } from "@arktype/util";
22
import {
33
UserTypes,
44
extendedScope,
@@ -17,7 +17,7 @@ import { SystemsInput, WorldInput } from "./input";
1717
import { CONFIG_DEFAULTS } from "./defaults";
1818
import { Tables } from "@latticexyz/store/internal";
1919
import { resolveSystems } from "./systems";
20-
import { resolveNamespacedTables, validateNamespaces } from "./namespaces";
20+
import { resolveNamespacedTables } from "./namespaces";
2121
import { resolveCodegen } from "./codegen";
2222
import { resolveDeploy } from "./deploy";
2323

@@ -29,7 +29,8 @@ export type validateWorld<world> = {
2929
: key extends "enums"
3030
? narrow<world[key]>
3131
: key extends "namespaces"
32-
? validateNamespaces<world[key], extendedScope<world>>
32+
? // ? validateNamespaces<world[key], extendedScope<world>>
33+
ErrorMessage<`Namespaces config will be enabled soon.`>
3334
: key extends keyof WorldInput
3435
? conform<world[key], WorldInput[key]>
3536
: world[key];
@@ -108,11 +109,3 @@ export function defineWorld<const world>(world: validateWorld<world>): resolveWo
108109
validateWorld(world);
109110
return resolveWorld(world) as unknown as resolveWorld<world>;
110111
}
111-
112-
// Temporary external export of defineWorld with namespaces disabled
113-
export function defineWorldWithoutNamespaces<const world>(
114-
world: validateWorld<world> & { namespaces?: `Namespaces will be enabled soon` },
115-
): resolveWorld<world> {
116-
validateWorld(world);
117-
return resolveWorld(world) as unknown as resolveWorld<world>;
118-
}

packages/world/ts/exports/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
export { helloWorldEvent, worldDeployedEvent } from "../worldEvents";
88

9-
export { defineWorldWithoutNamespaces as defineWorld } from "../config/v2/world";
9+
export { defineWorld } from "../config/v2/world";
1010
export type { World } from "../config/v2/output";

0 commit comments

Comments
 (0)