@@ -4,58 +4,91 @@ export type JsonDbTypeMap = {
44} ;
55
66export type JsonDbOptions = {
7+ /** Project root used to resolve relative config paths. Defaults to process.cwd(). */
78 cwd ?: string ;
9+ /** Explicit config file path. Defaults to jsondb.config.mjs/js lookup from cwd. */
810 configPath ?: string ;
11+ /** Fixture source folder. Defaults to "./db". */
912 dbDir ?: string ;
13+ /** Backwards-compatible fixture source folder alias. If set, it wins over dbDir. */
1014 sourceDir ?: string ;
15+ /** Generated runtime output folder. Defaults to "./.jsondb". */
1116 stateDir ?: string ;
17+ /** "mirror" keeps source fixtures unchanged; "source" may write generated ids back to plain .json fixtures. */
1218 mode ?: 'mirror' | 'source' ;
19+ /** Run sync automatically when opening the package API. */
1320 syncOnOpen ?: boolean ;
21+ /** Keep valid resources available when one source file has diagnostics. */
1422 allowSourceErrors ?: boolean ;
1523 types ?: {
24+ /** Generate TypeScript types during sync. */
1625 enabled ?: boolean ;
26+ /** Gitignored generated type output. Defaults to "./.jsondb/types/index.ts". */
1727 outFile ?: string ;
28+ /** Optional committed copy for app/CI imports. */
1829 commitOutFile ?: string | null ;
30+ /** Emit readonly object properties in generated types. */
1931 useReadonly ?: boolean ;
32+ /** Emit JSDoc from schema field descriptions. */
2033 emitComments ?: boolean ;
34+ /** Export JsonDbCollections, JsonDbDocuments, and JsonDbTypes helpers. */
2135 exportRuntimeHelpers ?: boolean ;
2236 } ;
2337 schema ?: {
38+ /** Which inputs define schemas. "auto" uses schema files when present and otherwise infers from data. */
2439 source ?: 'auto' | 'data' | 'schema' ;
40+ /** Allow JSONC source files. */
2541 allowJsonc ?: boolean ;
42+ /** How schema-backed resources handle fields not declared by schema. */
2643 unknownFields ?: 'allow' | 'warn' | 'error' ;
44+ /** Future migration policy for safe additive changes. */
2745 additiveChanges ?: 'auto' | 'manual' ;
46+ /** Future migration policy for destructive changes. */
2847 destructiveChanges ?: 'manual' ;
48+ /** Future migration policy for field type changes. */
2949 typeChanges ?: 'manual' ;
3050 } ;
3151 defaults ?: {
52+ /** Apply schema defaults on create through package, REST, and GraphQL writes. */
3253 applyOnCreate ?: boolean ;
54+ /** Apply defaults during safe additive mirror sync. */
3355 applyOnSafeMigration ?: boolean ;
3456 } ;
3557 seed ?: {
58+ /** Generate mock runtime rows for schema-only resources with empty seed data. */
3659 generateFromSchema ?: boolean ;
60+ /** Number of mock rows to generate when generateFromSchema is true. */
3761 generatedCount ?: number ;
3862 } ;
63+ /** Per-collection overrides such as custom id field names. */
3964 collections ?: Record < string , { idField ?: string } > ;
4065 server ?: {
66+ /** Local HTTP host. Defaults to "127.0.0.1". */
4167 host ?: string ;
68+ /** Local HTTP port. Defaults to 7331. */
4269 port ?: number ;
70+ /** Maximum JSON request body size in bytes. Defaults to 1048576. */
4371 maxBodyBytes ?: number ;
4472 } ;
4573 rest ?: {
74+ /** Enable generated REST routes. */
4675 enabled ?: boolean ;
4776 } ;
4877 graphql ?: {
78+ /** Enable the focused dependency-free GraphQL endpoint. */
4979 enabled ?: boolean ;
80+ /** GraphQL HTTP path. Defaults to "/graphql". */
5081 path ?: string ;
5182 } ;
5283 mock ?: {
84+ /** Local response delay in ms, [minMs, maxMs], or an object range. Defaults to [30, 100]. Use 0 to disable. */
5385 delay ?: number | [ number , number ] | {
5486 minMs ?: number ;
5587 maxMs ?: number ;
5688 min ?: number ;
5789 max ?: number ;
5890 } | null ;
91+ /** Random local error rate or detailed error settings. Defaults to no random errors. */
5992 errors ?: number | {
6093 rate ?: number ;
6194 probability ?: number ;
@@ -65,11 +98,14 @@ export type JsonDbOptions = {
6598 } ;
6699 generate ?: {
67100 hono ?: {
101+ /** Output folder for generated starter code. */
68102 outDir ?: string ;
103+ /** API modules to generate. */
69104 api ?: Array < 'rest' | 'graphql' > | 'rest' | 'graphql' | 'rest,graphql' | 'none' ;
70105 db ?: 'sqlite' ;
71106 app ?: 'standalone' | 'module' ;
72107 runtime ?: 'node-sqlite' ;
108+ /** Include fixture seed support in generated starter code. */
73109 seed ?: false | 'fixtures' ;
74110 } ;
75111 } ;
0 commit comments