diff --git a/packages/store/ts/config/v2/defaults.ts b/packages/store/ts/config/v2/defaults.ts index e2a8248877c..807941d34a4 100644 --- a/packages/store/ts/config/v2/defaults.ts +++ b/packages/store/ts/config/v2/defaults.ts @@ -10,6 +10,7 @@ export const CODEGEN_DEFAULTS = { export type CODEGEN_DEFAULTS = typeof CODEGEN_DEFAULTS; export const TABLE_CODEGEN_DEFAULTS = { + outputDirectory: "tables", tableIdArgument: false, storeArgument: false, } as const; diff --git a/packages/store/ts/config/v2/store.test.ts b/packages/store/ts/config/v2/store.test.ts index d79774c3e63..293d0ab2c04 100644 --- a/packages/store/ts/config/v2/store.test.ts +++ b/packages/store/ts/config/v2/store.test.ts @@ -38,11 +38,7 @@ describe("defineStore", () => { key: ["age"], name: "Example", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -93,11 +89,7 @@ describe("defineStore", () => { key: ["age"], name: "Example", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -147,11 +139,7 @@ describe("defineStore", () => { key: ["age", "id"], name: "Example", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -202,11 +190,7 @@ describe("defineStore", () => { key: ["firstKey", "firstAge"], name: "First", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -229,11 +213,7 @@ describe("defineStore", () => { key: ["secondKey", "secondAge"], name: "Second", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -288,11 +268,7 @@ describe("defineStore", () => { key: ["firstKey", "firstAge"], name: "First", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -315,11 +291,7 @@ describe("defineStore", () => { key: ["secondKey", "secondAge"], name: "Second", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -430,11 +402,7 @@ describe("defineStore", () => { key: ["name"], name: "Example", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, diff --git a/packages/store/ts/config/v2/storeWithShorthands.test.ts b/packages/store/ts/config/v2/storeWithShorthands.test.ts index c8045a1d352..ce0a07de1a9 100644 --- a/packages/store/ts/config/v2/storeWithShorthands.test.ts +++ b/packages/store/ts/config/v2/storeWithShorthands.test.ts @@ -26,11 +26,7 @@ describe("defineStoreWithShorthands", () => { key: ["id"], name: "Name", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -68,11 +64,7 @@ describe("defineStoreWithShorthands", () => { key: ["id"], name: "Name", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -114,11 +106,7 @@ describe("defineStoreWithShorthands", () => { key: ["id"], name: "Example", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -160,11 +148,7 @@ describe("defineStoreWithShorthands", () => { key: ["id"], name: "Example", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, diff --git a/packages/store/ts/config/v2/table.test.ts b/packages/store/ts/config/v2/table.test.ts index e159675d769..c9e77836e44 100644 --- a/packages/store/ts/config/v2/table.test.ts +++ b/packages/store/ts/config/v2/table.test.ts @@ -65,7 +65,7 @@ describe("resolveTable", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, + dataStruct: true as boolean, }, type: "table", @@ -93,7 +93,7 @@ describe("resolveTable", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, + dataStruct: false as boolean, }, type: "table", @@ -127,7 +127,7 @@ describe("resolveTable", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, + dataStruct: true as boolean, }, type: "table", diff --git a/packages/store/ts/config/v2/table.ts b/packages/store/ts/config/v2/table.ts index 2b2922e44f7..cd5f59003b0 100644 --- a/packages/store/ts/config/v2/table.ts +++ b/packages/store/ts/config/v2/table.ts @@ -106,26 +106,22 @@ export type resolveTableCodegen = evaluate<{ ? undefined extends input["codegen"][key] ? key extends "dataStruct" ? boolean - : key extends "outputDirectory" - ? string - : key extends keyof TABLE_CODEGEN_DEFAULTS - ? TABLE_CODEGEN_DEFAULTS[key] - : never + : key extends keyof TABLE_CODEGEN_DEFAULTS + ? TABLE_CODEGEN_DEFAULTS[key] + : never : input["codegen"][key] : // dataStruct isn't narrowed, because its value is conditional on the number of value schema fields key extends "dataStruct" ? boolean - : key extends "outputDirectory" - ? string - : key extends keyof TABLE_CODEGEN_DEFAULTS - ? TABLE_CODEGEN_DEFAULTS[key] - : never; + : key extends keyof TABLE_CODEGEN_DEFAULTS + ? TABLE_CODEGEN_DEFAULTS[key] + : never; }>; export function resolveTableCodegen(input: input): resolveTableCodegen { const options = input.codegen; return { - outputDirectory: get(options, "outputDirectory") ?? "tables", + outputDirectory: get(options, "outputDirectory") ?? TABLE_CODEGEN_DEFAULTS.outputDirectory, tableIdArgument: get(options, "tableIdArgument") ?? TABLE_CODEGEN_DEFAULTS.tableIdArgument, storeArgument: get(options, "storeArgument") ?? TABLE_CODEGEN_DEFAULTS.storeArgument, // dataStruct is true if there are at least 2 value fields diff --git a/packages/world/ts/config/v2/world.test.ts b/packages/world/ts/config/v2/world.test.ts index 537fda7f3ed..4ad4a7d4de6 100644 --- a/packages/world/ts/config/v2/world.test.ts +++ b/packages/world/ts/config/v2/world.test.ts @@ -61,11 +61,7 @@ describe("defineWorld", () => { key: ["id"], name: "ExampleTable", namespace: "ExampleNamespace", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -128,11 +124,7 @@ describe("defineWorld", () => { key: ["id"], name: "ExampleTable", namespace: "ExampleNamespace", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -244,7 +236,6 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, dataStruct: true as boolean, }, type: "table", @@ -298,7 +289,6 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, dataStruct: true as boolean, }, type: "table", @@ -351,7 +341,6 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, dataStruct: false as boolean, }, type: "table", @@ -406,7 +395,6 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, dataStruct: false as boolean, }, type: "table", @@ -433,7 +421,6 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, dataStruct: false as boolean, }, type: "table", @@ -492,7 +479,6 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, dataStruct: false as boolean, }, type: "table", @@ -519,7 +505,6 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, dataStruct: false as boolean, }, type: "table", @@ -634,7 +619,6 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, dataStruct: true as boolean, }, type: "table", diff --git a/packages/world/ts/config/v2/worldWithShorthands.test.ts b/packages/world/ts/config/v2/worldWithShorthands.test.ts index b826bc7d677..c7ec8e2be71 100644 --- a/packages/world/ts/config/v2/worldWithShorthands.test.ts +++ b/packages/world/ts/config/v2/worldWithShorthands.test.ts @@ -51,11 +51,7 @@ describe("defineWorldWithShorthands", () => { key: ["id"], name: "ExampleTable", namespace: "ExampleNamespace", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -124,11 +120,7 @@ describe("defineWorldWithShorthands", () => { key: ["id"], name: "ExampleTable", namespace: "ExampleNamespace", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -174,11 +166,7 @@ describe("defineWorldWithShorthands", () => { key: ["id"], name: "Name", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -217,11 +205,7 @@ describe("defineWorldWithShorthands", () => { key: ["id"], name: "Name", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: false as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -262,11 +246,7 @@ describe("defineWorldWithShorthands", () => { key: ["id"], name: "Example", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, }, @@ -307,11 +287,7 @@ describe("defineWorldWithShorthands", () => { key: ["id"], name: "Example", namespace: "", - codegen: { - ...TABLE_CODEGEN_DEFAULTS, - outputDirectory: "tables" as string, - dataStruct: true as boolean, - }, + codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", deploy: TABLE_DEPLOY_DEFAULTS, },