mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-21 21:09:49 +08:00
## Summary - add a public `defineStackConfig` helper and `StackConfig` type for nested config authoring - emit helper-based nested config files from the CLI and local emulator - update type coverage and e2e expectations for the new `stack.config` format ## Testing - pnpm --filter ./packages/stack-shared typecheck - pnpm --filter ./packages/stack-cli typecheck - pnpm --filter ./apps/backend typecheck - pnpm --filter ./apps/e2e typecheck <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Type-safe configuration API with compile-time validation * New config rendering utility for producing typed config files * Public local-emulator settings and a public helper to detect emulator mode * Added --overwrite flag for config pull * **Improvements** * Stronger validation and clearer errors for invalid or conflicting config shapes * Config output now includes explicit TypeScript typing * **Tests** * Added and strengthened tests for config authoring, rendering, CLI behavior, and emulator flows <!-- end of auto-generated comment: release notes by coderabbit.ai -->
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { typeAssertExtends } from "./utils/types";
|
|
import { defineStackConfig, type StackConfig } from "./config-authoring";
|
|
|
|
const validConfig = defineStackConfig({
|
|
payments: {
|
|
items: {
|
|
todos: {
|
|
displayName: "Todo Slots",
|
|
customerType: "user",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
typeAssertExtends<typeof validConfig, StackConfig>()();
|
|
|
|
it("returns its input unchanged", () => {
|
|
expect(defineStackConfig(validConfig)).toBe(validConfig);
|
|
});
|
|
|
|
defineStackConfig({
|
|
// @ts-expect-error Top-level dot notation should not be accepted in typed config files.
|
|
"payments.items": {
|
|
todos: {
|
|
displayName: "Todo Slots",
|
|
customerType: "user",
|
|
},
|
|
},
|
|
});
|
|
|
|
defineStackConfig({
|
|
payments: {
|
|
// @ts-expect-error Unknown keys should not be accepted in typed config files.
|
|
missingField: true,
|
|
},
|
|
});
|
|
|
|
defineStackConfig({
|
|
payments: {
|
|
items: {
|
|
todos: {
|
|
displayName: "Todo Slots",
|
|
// @ts-expect-error Invalid enum values should fail type-checking.
|
|
customerType: "workspace",
|
|
},
|
|
},
|
|
},
|
|
});
|