@kronor/dtv 9.2.1 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -89,6 +89,9 @@ export async function loadConfig(configPath) {
|
|
|
89
89
|
if (cfg.scalars !== undefined && !isRecord(cfg.scalars)) {
|
|
90
90
|
throw new Error('Config.scalars must be an object when provided');
|
|
91
91
|
}
|
|
92
|
+
if (cfg.immutableTypes !== undefined && typeof cfg.immutableTypes !== 'boolean') {
|
|
93
|
+
throw new Error('Config.immutableTypes must be a boolean when provided');
|
|
94
|
+
}
|
|
92
95
|
if (cfg.debug !== undefined) {
|
|
93
96
|
if (!isRecord(cfg.debug))
|
|
94
97
|
throw new Error('Config.debug must be an object when provided');
|
|
@@ -672,6 +672,7 @@ export async function runTypegen(args) {
|
|
|
672
672
|
'',
|
|
673
673
|
renderTsFromSchema(reachable, {
|
|
674
674
|
scalars: config.scalars,
|
|
675
|
+
immutableTypes: config.immutableTypes === true,
|
|
675
676
|
includeGraphqlTypeComments: config.debug?.includeGraphqlTypeComments === true,
|
|
676
677
|
exportTypes: false
|
|
677
678
|
}).trimEnd(),
|
|
@@ -45,7 +45,7 @@ export type Opaque<Value> = IsAny<Value> extends true ? true : unknown extends V
|
|
|
45
45
|
/** Non-distributive so that literal unions (Hasura enums) describe as one word. */
|
|
46
46
|
export type DescribeType<Value> = [
|
|
47
47
|
Value
|
|
48
|
-
] extends [string] ? 'string' : [Value] extends [number] ? 'number' : [Value] extends [boolean] ? 'boolean' : [Value] extends [Date] ? 'Date' : [Value] extends [readonly unknown[]] ? 'a list' : [Value] extends [object] ? 'an object' : 'unknown';
|
|
48
|
+
] extends [string] ? 'string' : [Value] extends [number] ? 'number' : [Value] extends [boolean] ? 'boolean' : [Value] extends [Date] ? 'Date' : [Value] extends [unknown[]] ? 'a list' : [Value] extends [readonly unknown[]] ? 'a readonly list' : [Value] extends [object] ? 'an object' : 'unknown';
|
|
49
49
|
/** Decrementing counter that bounds type-level recursion. */
|
|
50
50
|
export type NestingDepth = {
|
|
51
51
|
0: never;
|
|
@@ -20,6 +20,12 @@ export type DtvTypegenConfig = {
|
|
|
20
20
|
fileNamePattern: string;
|
|
21
21
|
};
|
|
22
22
|
scalars?: Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Emit row fields as `readonly` and lists as `ReadonlyArray` (default false), so code that
|
|
25
|
+
* changes a row it got from the server does not compile. Same name and meaning as the
|
|
26
|
+
* graphql-codegen option.
|
|
27
|
+
*/
|
|
28
|
+
immutableTypes?: boolean;
|
|
23
29
|
debug?: {
|
|
24
30
|
/** Include original GraphQL type references as comments in generated output. */
|
|
25
31
|
includeGraphqlTypeComments?: boolean;
|
package/docs/typegen.md
CHANGED
|
@@ -64,6 +64,10 @@ const config: DtvTypegenConfig = {
|
|
|
64
64
|
// jsonb: 'unknown'
|
|
65
65
|
},
|
|
66
66
|
|
|
67
|
+
// Optional: emit row fields as `readonly` and lists as `ReadonlyArray` (default false),
|
|
68
|
+
// so code that changes a row it got from the server does not compile.
|
|
69
|
+
// immutableTypes: true,
|
|
70
|
+
|
|
67
71
|
debug: {
|
|
68
72
|
// When true, include original GraphQL type refs as comments
|
|
69
73
|
includeGraphqlTypeComments: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kronor/dtv",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "Schema-driven, declarative table views with advanced filtering, data fetching and AI-assisted filter generation.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"react-dom": "^19.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@kronor/hasura-graphql": "^0.1.
|
|
61
|
+
"@kronor/hasura-graphql": "^0.1.6",
|
|
62
62
|
"commander": "^14.0.0",
|
|
63
63
|
"fast-glob": "^3.3.3",
|
|
64
64
|
"graphql": "^16.14.2",
|