@kronor/dtv 7.6.2 → 7.7.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.
- package/README.md +17 -14
- package/bin/dtv.js +0 -0
- package/dist/cli/typegen/runTypegen.js +2 -43
- package/dist/index.es.js +7098 -7043
- package/dist/types/dsl/columns.d.ts +5 -53
- package/dist/types/dsl/filters.d.ts +8 -39
- package/dist/types/dsl/hasura.d.ts +3 -68
- package/dist/types/dsl/queryForRow.d.ts +3 -5
- package/dist/types/framework/column-definition.d.ts +4 -227
- package/dist/types/framework/data.d.ts +2 -2
- package/dist/types/framework/filter-form-state.d.ts +2 -2
- package/dist/types/framework/graphql/hasura-filter-expression.d.ts +1 -49
- package/dist/types/framework/graphql/index.d.ts +4 -6
- package/dist/types/framework/graphql/query.d.ts +1 -47
- package/dist/types/framework/order-direction.d.ts +2 -2
- package/dist/types/lib/index.d.ts +3 -0
- package/package.json +86 -94
- package/dist/cli/typegen/schemaToTs.js +0 -166
- package/dist/types/dsl/internal/queryForRow.d.ts +0 -48
- package/dist/types/framework/graphql/hasura-filter-object.d.ts +0 -47
- package/dist/types/framework/typelevel.d.ts +0 -5
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Declarative Table View System
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A React + TypeScript library for building schema-driven, declarative table views with advanced filtering, data fetching, and AI-assisted filter generation.
|
|
4
|
+
|
|
5
|
+
It is one package of the [declarative-table-view](../../README.md) monorepo, and builds on
|
|
6
|
+
[`@kronor/hasura-graphql`](../hasura-graphql) for its GraphQL/Hasura AST layer: Hasura filter
|
|
7
|
+
expressions, query documents and the row-typed query DSL all come from there.
|
|
4
8
|
|
|
5
9
|
## Library Consumption
|
|
6
10
|
|
|
@@ -63,6 +67,8 @@ React and ReactDOM 19 are peer dependencies; ensure they are installed in the ho
|
|
|
63
67
|
- `src/framework/`: Table/view schema, filter logic, state, and data fetching.
|
|
64
68
|
- `src/components/`: UI components, including filter forms, AI assistant, and table rendering.
|
|
65
69
|
- `src/views/`: View definitions, each exporting a `View` object with schema, columns, and query config.
|
|
70
|
+
- `src/dsl/`: Authoring helpers for views, columns and filters. Query/Hasura builders are
|
|
71
|
+
re-exported from `@kronor/hasura-graphql`.
|
|
66
72
|
|
|
67
73
|
## Key Patterns & Conventions
|
|
68
74
|
- **Filter Schema:** Filters are defined in `FilterFieldSchema` objects. Each filter requires an `aiGenerated: boolean` field. See `src/framework/filters.ts` for types and helpers.
|
|
@@ -92,6 +98,7 @@ Core runtime capabilities:
|
|
|
92
98
|
## Development
|
|
93
99
|
|
|
94
100
|
### Install dependencies
|
|
101
|
+
Run from the monorepo root; npm links the workspace packages together.
|
|
95
102
|
```sh
|
|
96
103
|
npm install
|
|
97
104
|
```
|
|
@@ -132,13 +139,15 @@ DTV ships a CLI command for generating TypeScript types from a Hasura GraphQL sc
|
|
|
132
139
|
|
|
133
140
|
## Release Process
|
|
134
141
|
|
|
135
|
-
|
|
142
|
+
Releases are driven from the monorepo root, one package at a time. See the
|
|
143
|
+
[root README](../../README.md#releasing) for the full flow.
|
|
136
144
|
|
|
137
|
-
### Run a release
|
|
138
145
|
```sh
|
|
139
|
-
npm run release
|
|
146
|
+
npm run release -- --package=dtv # from the repo root; --package=dtv is the default
|
|
140
147
|
```
|
|
141
|
-
|
|
148
|
+
|
|
149
|
+
The script lints, builds and tests the whole workspace, builds the library
|
|
150
|
+
bundle, then bumps, tags (`v<version>`), pushes and publishes.
|
|
142
151
|
|
|
143
152
|
### Options / Flags
|
|
144
153
|
```sh
|
|
@@ -153,14 +162,8 @@ npm run release -- --allow-dirty # Allow running with uncommitted changes (a
|
|
|
153
162
|
- You must be authenticated with npm (`npm login`).
|
|
154
163
|
- Git working tree must be clean (unless using `--allow-dirty`).
|
|
155
164
|
- CI should pass for the commit you are releasing.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
2. Builds application (`npm run build`).
|
|
160
|
-
3. Runs unit tests (Jest) and E2E tests (Playwright).
|
|
161
|
-
4. Builds library bundle (`npm run build:lib`).
|
|
162
|
-
5. Bumps version via `npm version <type>` (commit + tag).
|
|
163
|
-
6. Pushes commit and tags.
|
|
164
|
-
7. Publishes to npm (`npm publish --access public`).
|
|
165
|
+
- If `@kronor/hasura-graphql` changed, release it first
|
|
166
|
+
(`npm run release -- --package=hasura-graphql`). A dtv release aborts when its
|
|
167
|
+
declared dependency range has no published match.
|
|
165
168
|
|
|
166
169
|
Use `--dry` first if you want to verify everything without changing the version or publishing.
|
package/bin/dtv.js
CHANGED
|
File without changes
|
|
@@ -2,53 +2,12 @@ import * as path from 'node:path';
|
|
|
2
2
|
import * as fs from 'node:fs/promises';
|
|
3
3
|
import fg from 'fast-glob';
|
|
4
4
|
import ts from 'typescript';
|
|
5
|
-
import { getIntrospectionQuery, buildClientSchema } from 'graphql';
|
|
6
5
|
import { loadConfig } from '../config/loadConfig.js';
|
|
7
|
-
import { collectReachableTypes, renderTsFromSchema, unwrapCollectionElementType } from '
|
|
8
|
-
function toPascalCase(input) {
|
|
9
|
-
return input
|
|
10
|
-
.replace(/[^a-zA-Z0-9]+/g, ' ')
|
|
11
|
-
.trim()
|
|
12
|
-
.split(' ')
|
|
13
|
-
.filter(Boolean)
|
|
14
|
-
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
15
|
-
.join('');
|
|
16
|
-
}
|
|
17
|
-
function toIdentifier(pascal) {
|
|
18
|
-
if (/^[A-Za-z_]/.test(pascal))
|
|
19
|
-
return pascal;
|
|
20
|
-
return `_${pascal}`;
|
|
21
|
-
}
|
|
22
|
-
function singleQuoteStringLiteral(value) {
|
|
23
|
-
return `'${value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n').replace(/\r/g, '\\r')}'`;
|
|
24
|
-
}
|
|
6
|
+
import { collectReachableTypes, fetchSchema, renderTsFromSchema, singleQuoteStringLiteral, toIdentifier, toPascalCase, unwrapCollectionElementType, } from '@kronor/hasura-graphql/typegen';
|
|
25
7
|
async function writeFileEnsuringDir(filePath, content) {
|
|
26
8
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
27
9
|
await fs.writeFile(filePath, content, 'utf8');
|
|
28
10
|
}
|
|
29
|
-
async function fetchSchema(endpoint, headers) {
|
|
30
|
-
const query = getIntrospectionQuery({ descriptions: true });
|
|
31
|
-
const res = await fetch(endpoint, {
|
|
32
|
-
method: 'POST',
|
|
33
|
-
headers: {
|
|
34
|
-
'content-type': 'application/json',
|
|
35
|
-
...headers
|
|
36
|
-
},
|
|
37
|
-
body: JSON.stringify({ query })
|
|
38
|
-
});
|
|
39
|
-
if (!res.ok) {
|
|
40
|
-
const text = await res.text().catch(() => '');
|
|
41
|
-
throw new Error(`Introspection request failed (${res.status} ${res.statusText}): ${text}`);
|
|
42
|
-
}
|
|
43
|
-
const json = await res.json();
|
|
44
|
-
if (json.errors && Array.isArray(json.errors) && json.errors.length) {
|
|
45
|
-
throw new Error(`Introspection returned errors: ${JSON.stringify(json.errors, null, 2)}`);
|
|
46
|
-
}
|
|
47
|
-
if (!json.data) {
|
|
48
|
-
throw new Error('Introspection response missing data');
|
|
49
|
-
}
|
|
50
|
-
return buildClientSchema(json.data);
|
|
51
|
-
}
|
|
52
11
|
function applyFileNamePattern(pattern, view) {
|
|
53
12
|
return pattern
|
|
54
13
|
.replace(/\{viewId\}/g, view.viewId)
|
|
@@ -497,7 +456,7 @@ export async function runTypegen(args) {
|
|
|
497
456
|
throw new Error(`No view found with id ${JSON.stringify(args.onlyViewId)}. `
|
|
498
457
|
+ `Sample discovered view ids: ${sample.join(', ')}${sample.length === 25 ? ', ...' : ''}`);
|
|
499
458
|
}
|
|
500
|
-
const schema = await fetchSchema(config.schema.endpoint, config.schema.headers ?? {});
|
|
459
|
+
const schema = await fetchSchema({ endpoint: config.schema.endpoint, headers: config.schema.headers ?? {} });
|
|
501
460
|
const queryType = schema.getQueryType();
|
|
502
461
|
if (!queryType)
|
|
503
462
|
throw new Error('Schema has no Query type');
|