@kronor/dtv 7.6.3 → 7.7.1

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/package.json CHANGED
@@ -1,98 +1,90 @@
1
1
  {
2
- "name": "@kronor/dtv",
3
- "version": "7.6.3",
4
- "description": "Schema-driven, declarative table views with advanced filtering, data fetching and AI-assisted filter generation.",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/kronor-io/declarative-table-view.git"
8
- },
9
- "homepage": "https://github.com/kronor-io/declarative-table-view#readme",
10
- "bugs": {
11
- "url": "https://github.com/kronor-io/declarative-table-view/issues"
12
- },
13
- "type": "module",
14
- "bin": {
15
- "dtv": "bin/dtv.js"
16
- },
17
- "files": [
18
- "bin",
19
- "dist/index.es.js",
20
- "dist/cli",
21
- "dist/types",
22
- "docs",
23
- "README.md"
24
- ],
25
- "scripts": {
26
- "dev": "vite",
27
- "build": "tsc -b && vite build",
28
- "build:cli": "tsc -p tsconfig.cli.json",
29
- "build:lib": "npm run build:cli && tsc -p tsconfig.lib.json && vite build --config vite.lib.config.ts",
30
- "prepack": "npm run build:lib",
31
- "prepublishOnly": "npm run lint && npm run test-unit:all",
32
- "dev:playground": "npm run build:lib -- --watch & vite --config vite.playground.config.ts",
33
- "clean": "rimraf dist",
34
- "lint": "eslint .",
35
- "preview": "vite preview",
36
- "test": "playwright test",
37
- "test-unit": "jest --config jest.config.js",
38
- "test-unit:cli": "jest --config jest.cli.config.js",
39
- "test-unit:all": "npm run test-unit && npm run test-unit:cli",
40
- "prepare": "husky install",
41
- "release": "node scripts/release.mjs",
42
- "ai:gemini-regression": "tsx scripts/ai-regression/gemini-regression.ts",
43
- "ai:gemini-list-models": "tsx scripts/ai-regression/gemini-list-models.ts"
44
- },
45
- "exports": {
46
- ".": {
47
- "types": "./dist/types/lib/index.d.ts",
48
- "import": "./dist/index.es.js"
2
+ "name": "@kronor/dtv",
3
+ "version": "7.7.1",
4
+ "description": "Schema-driven, declarative table views with advanced filtering, data fetching and AI-assisted filter generation.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/kronor-io/declarative-table-view.git"
49
8
  },
50
- "./typegen": {
51
- "types": "./dist/types/typegen/index.d.ts",
52
- "default": "./dist/index.es.js"
9
+ "homepage": "https://github.com/kronor-io/declarative-table-view#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/kronor-io/declarative-table-view/issues"
12
+ },
13
+ "type": "module",
14
+ "bin": {
15
+ "dtv": "bin/dtv.js"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "dist/index.es.js",
20
+ "dist/cli",
21
+ "dist/types",
22
+ "docs",
23
+ "README.md"
24
+ ],
25
+ "scripts": {
26
+ "dev": "vite",
27
+ "build": "tsc -b && vite build",
28
+ "build:cli": "tsc -p tsconfig.cli.json",
29
+ "build:lib": "npm run build --workspace @kronor/hasura-graphql && npm run build:cli && tsc -p tsconfig.lib.json && vite build --config vite.lib.config.ts",
30
+ "prepack": "npm run build:lib",
31
+ "prepublishOnly": "npm run lint && npm run test-unit:all",
32
+ "dev:playground": "npm run build:lib -- --watch & vite --config vite.playground.config.ts",
33
+ "clean": "rimraf dist",
34
+ "lint": "eslint .",
35
+ "preview": "vite preview",
36
+ "test": "playwright test",
37
+ "test-unit": "jest --config jest.config.js",
38
+ "test-unit:cli": "jest --config jest.cli.config.js",
39
+ "test-unit:all": "npm run test-unit && npm run test-unit:cli",
40
+ "ai:gemini-regression": "tsx scripts/ai-regression/gemini-regression.ts",
41
+ "ai:gemini-list-models": "tsx scripts/ai-regression/gemini-list-models.ts"
42
+ },
43
+ "exports": {
44
+ ".": {
45
+ "types": "./dist/types/lib/index.d.ts",
46
+ "import": "./dist/index.es.js"
47
+ },
48
+ "./typegen": {
49
+ "types": "./dist/types/typegen/index.d.ts",
50
+ "default": "./dist/index.es.js"
51
+ }
52
+ },
53
+ "main": "./dist/index.es.js",
54
+ "module": "./dist/index.es.js",
55
+ "types": "./dist/types/lib/index.d.ts",
56
+ "peerDependencies": {
57
+ "react": "^19.0.0",
58
+ "react-dom": "^19.0.0"
59
+ },
60
+ "dependencies": {
61
+ "@kronor/hasura-graphql": "^0.1.0",
62
+ "commander": "^14.0.0",
63
+ "fast-glob": "^3.3.3",
64
+ "graphql": "^16.14.2",
65
+ "graphql-request": "^7.4.0",
66
+ "primereact": "^10.9.7",
67
+ "typescript": "~5.7.2"
68
+ },
69
+ "devDependencies": {
70
+ "@playwright/test": "^1.52.0",
71
+ "@tailwindcss/vite": "^4.1.1",
72
+ "@types/dom-speech-recognition": "^0.0.6",
73
+ "@types/jest": "^30.0.0",
74
+ "@types/node": "^22.15.21",
75
+ "@types/react": "^19.1.4",
76
+ "@types/react-dom": "^19.1.5",
77
+ "@vitejs/plugin-react": "^4.3.4",
78
+ "jest": "^30.0.3",
79
+ "jest-environment-jsdom": "^30.0.4",
80
+ "primeicons": "^7.0.0",
81
+ "react": "^19.0.0",
82
+ "react-dom": "^19.0.0",
83
+ "rimraf": "^5.0.5",
84
+ "tailwindcss": "^4.1.1",
85
+ "ts-jest": "^29.4.0",
86
+ "tsx": "^4.20.5",
87
+ "vite": "^6.2.0",
88
+ "vite-plugin-css-injected-by-js": "^3.5.2"
53
89
  }
54
- },
55
- "main": "./dist/index.es.js",
56
- "module": "./dist/index.es.js",
57
- "types": "./dist/types/lib/index.d.ts",
58
- "peerDependencies": {
59
- "react": "^19.0.0",
60
- "react-dom": "^19.0.0"
61
- },
62
- "dependencies": {
63
- "commander": "^14.0.0",
64
- "fast-glob": "^3.3.3",
65
- "graphql": "^16.14.2",
66
- "graphql-request": "^7.4.0",
67
- "primereact": "^10.9.7",
68
- "typescript": "~5.7.2"
69
- },
70
- "devDependencies": {
71
- "@eslint/js": "^9.21.0",
72
- "@playwright/test": "^1.52.0",
73
- "@tailwindcss/vite": "^4.1.1",
74
- "@types/dom-speech-recognition": "^0.0.6",
75
- "@types/jest": "^30.0.0",
76
- "@types/node": "^22.15.21",
77
- "@types/react": "^19.1.4",
78
- "@types/react-dom": "^19.1.5",
79
- "@vitejs/plugin-react": "^4.3.4",
80
- "eslint": "^9.21.0",
81
- "eslint-plugin-react-hooks": "^5.1.0",
82
- "eslint-plugin-react-refresh": "^0.4.19",
83
- "globals": "^15.15.0",
84
- "husky": "^8.0.3",
85
- "jest": "^30.0.3",
86
- "jest-environment-jsdom": "^30.0.4",
87
- "primeicons": "^7.0.0",
88
- "react": "^19.0.0",
89
- "react-dom": "^19.0.0",
90
- "rimraf": "^5.0.5",
91
- "tailwindcss": "^4.1.1",
92
- "ts-jest": "^29.4.0",
93
- "tsx": "^4.20.5",
94
- "typescript-eslint": "^8.24.1",
95
- "vite": "^6.2.0",
96
- "vite-plugin-css-injected-by-js": "^3.5.2"
97
- }
98
90
  }
@@ -1,166 +0,0 @@
1
- import { getNamedType, isEnumType, isInterfaceType, isInputObjectType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType } from 'graphql';
2
- function safePropKey(key) {
3
- return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key) ? key : JSON.stringify(key);
4
- }
5
- function singleQuoteStringLiteral(value) {
6
- // Emit a TS string literal using single quotes.
7
- return `'${value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n').replace(/\r/g, '\\r')}'`;
8
- }
9
- export function unwrapCollectionElementType(fieldType) {
10
- // fieldType is usually [T!]! or [T!] etc. We want T.
11
- let t = fieldType;
12
- while (isNonNullType(t))
13
- t = t.ofType;
14
- if (isListType(t)) {
15
- t = t.ofType;
16
- while (isNonNullType(t))
17
- t = t.ofType;
18
- return getNamedType(t);
19
- }
20
- return getNamedType(t);
21
- }
22
- export function collectReachableTypes(_schema, roots) {
23
- const queue = [...roots];
24
- const seen = new Set();
25
- const add = (t) => {
26
- if (t.name.startsWith('__'))
27
- return;
28
- if (seen.has(t.name))
29
- return;
30
- seen.add(t.name);
31
- queue.push(t);
32
- };
33
- for (const r of roots) {
34
- if (!r.name.startsWith('__'))
35
- seen.add(r.name);
36
- }
37
- const out = [];
38
- while (queue.length) {
39
- const t = queue.shift();
40
- out.push(t);
41
- if (isObjectType(t) || isInterfaceType(t)) {
42
- const fields = t.getFields();
43
- for (const field of Object.values(fields)) {
44
- const named = getNamedType(field.type);
45
- add(named);
46
- }
47
- }
48
- else if (isUnionType(t)) {
49
- for (const possible of t.getTypes())
50
- add(possible);
51
- }
52
- }
53
- return out.sort((a, b) => a.name.localeCompare(b.name));
54
- }
55
- export function renderTsFromSchema(types, options) {
56
- const scalarMap = {
57
- ID: 'string',
58
- String: 'string',
59
- Boolean: 'boolean',
60
- Int: 'number',
61
- Float: 'number',
62
- json: 'any',
63
- jsonb: 'any',
64
- date: 'string',
65
- timestamptz: 'string',
66
- timestamp: 'string',
67
- uuid: 'string',
68
- ...(options?.scalars ?? {})
69
- };
70
- const renderGraphqlTypeRef = (t) => {
71
- if (isNonNullType(t))
72
- return `${renderGraphqlTypeRef(t.ofType)}!`;
73
- if (isListType(t))
74
- return `[${renderGraphqlTypeRef(t.ofType)}]`;
75
- return getNamedType(t).name;
76
- };
77
- const renderTypeRef = (t) => {
78
- if (!isNonNullType(t)) {
79
- return `${renderTypeRefNonNull(t)} | null`;
80
- }
81
- return renderTypeRefNonNull(t.ofType);
82
- };
83
- const renderTypeRefNonNull = (t) => {
84
- if (isNonNullType(t))
85
- return renderTypeRefNonNull(t.ofType);
86
- if (isListType(t))
87
- return `Array<${renderTypeRef(t.ofType)}>`;
88
- const named = getNamedType(t);
89
- if (isScalarType(named)) {
90
- return scalarMap[named.name] ?? 'unknown';
91
- }
92
- return named.name;
93
- };
94
- const includeGraphqlTypeComments = options?.includeGraphqlTypeComments === true;
95
- const exportTypes = options?.exportTypes !== false;
96
- const typePrefix = exportTypes ? 'export type' : 'type';
97
- const chunks = [];
98
- chunks.push('/* eslint-disable @typescript-eslint/no-unused-vars */');
99
- chunks.push('// This file is auto-generated by `dtv typegen`.');
100
- chunks.push('// Do not edit manually.');
101
- chunks.push('');
102
- for (const t of types) {
103
- const typeName = t.name;
104
- if (t.name.startsWith('__'))
105
- continue;
106
- if (isScalarType(t)) {
107
- continue;
108
- }
109
- if (isEnumType(t)) {
110
- const values = t.getValues().map(v => singleQuoteStringLiteral(v.name)).join(' | ');
111
- chunks.push(`${typePrefix} ${typeName} = ${values || 'never'};`);
112
- chunks.push('');
113
- continue;
114
- }
115
- if (isUnionType(t)) {
116
- const members = t.getTypes().map(m => m.name).join(' | ');
117
- chunks.push(`${typePrefix} ${typeName} = ${members || 'never'};`);
118
- chunks.push('');
119
- continue;
120
- }
121
- if (isObjectType(t) || isInterfaceType(t)) {
122
- const fields = t.getFields();
123
- const lines = [];
124
- for (const field of Object.values(fields)) {
125
- if (field.name.startsWith('__'))
126
- continue;
127
- const key = safePropKey(field.name);
128
- const tsType = renderTypeRef(field.type);
129
- if (includeGraphqlTypeComments) {
130
- lines.push(` ${key}: ${tsType}; // GraphQL: ${renderGraphqlTypeRef(field.type)}`);
131
- }
132
- else {
133
- lines.push(` ${key}: ${tsType};`);
134
- }
135
- }
136
- chunks.push(`${typePrefix} ${typeName} = {`);
137
- chunks.push(...lines);
138
- chunks.push('};');
139
- chunks.push('');
140
- continue;
141
- }
142
- if (isInputObjectType(t)) {
143
- // Not expected in reachable output types, but keep deterministic behavior.
144
- const fields = t.getFields();
145
- const lines = [];
146
- for (const field of Object.values(fields)) {
147
- const key = safePropKey(field.name);
148
- const tsType = renderTypeRef(field.type);
149
- if (includeGraphqlTypeComments) {
150
- lines.push(` ${key}: ${tsType}; // GraphQL: ${renderGraphqlTypeRef(field.type)}`);
151
- }
152
- else {
153
- lines.push(` ${key}: ${tsType};`);
154
- }
155
- }
156
- chunks.push(`${typePrefix} ${typeName} = {`);
157
- chunks.push(...lines);
158
- chunks.push('};');
159
- chunks.push('');
160
- continue;
161
- }
162
- chunks.push(`${typePrefix} ${typeName} = unknown;`);
163
- chunks.push('');
164
- }
165
- return chunks.join('\n');
166
- }
@@ -1,48 +0,0 @@
1
- import type { ArrayQuery, ArrayQueryForRow, ObjectQueryForRow, QueryForRowSafe, ValueQueryForRow } from '../../framework/column-definition';
2
- import type { HasuraFilterExpression } from '../../framework/graphql';
3
- import type { HasuraForRow } from '../hasura';
4
- type NonNullish<T> = Exclude<T, null | undefined>;
5
- type ElemOf<T> = T extends ReadonlyArray<infer E> ? E : never;
6
- type ArrayFieldKey<Row> = ArrayQueryForRow<Row> extends {
7
- field: infer F;
8
- } ? Extract<F, string> : never;
9
- type ObjectFieldKey<Row> = ObjectQueryForRow<Row> extends {
10
- field: infer F;
11
- } ? Extract<F, string> : never;
12
- export type QueryBuilder<Row> = {
13
- value: <K extends keyof Row & string>(args: {
14
- field: K;
15
- path?: string;
16
- }) => ValueQueryForRow<Row> & {
17
- field: K;
18
- };
19
- object: <K extends ObjectFieldKey<Row> & keyof Row & string, const SelectionSet extends readonly QueryForRowSafe<NonNullish<Row[K]>>[]>(args: {
20
- field: K;
21
- selectionSet: (q: QueryBuilder<NonNullish<Row[K]>>) => SelectionSet;
22
- path?: string;
23
- }) => ObjectQueryForRow<Row> & {
24
- field: K;
25
- selectionSet: SelectionSet;
26
- };
27
- array: <K extends ArrayFieldKey<Row> & keyof Row & string, const SelectionSet extends readonly QueryForRowSafe<NonNullish<ElemOf<NonNullish<Row[K]>>>>[]>(args: {
28
- field: K;
29
- selectionSet: (q: QueryBuilder<NonNullish<ElemOf<NonNullish<Row[K]>>>>) => SelectionSet;
30
- path?: string;
31
- orderBy?: ArrayQuery['orderBy'];
32
- distinctOn?: ArrayQuery['distinctOn'];
33
- limit?: number;
34
- where?: HasuraFilterExpression | ((h: HasuraForRow<NonNullish<ElemOf<NonNullish<Row[K]>>>>) => HasuraFilterExpression);
35
- }) => ArrayQueryForRow<Row> & {
36
- field: K;
37
- selectionSet: SelectionSet;
38
- };
39
- selection: <SelectionRow>() => QueryBuilder<SelectionRow>;
40
- __row: Row;
41
- };
42
- /**
43
- * Internal typed query builder scoped to a Row type.
44
- *
45
- * Not exported via the public DSL surface (yet).
46
- */
47
- export declare function queryForRow<Row>(): QueryBuilder<Row>;
48
- export {};
@@ -1,47 +0,0 @@
1
- export type HasuraComparable = string | number | Date;
2
- type ComparableOf<T> = Extract<T, HasuraComparable>;
3
- type StringOf<T> = Extract<T, string>;
4
- type InOf<T> = ReadonlyArray<NonNullable<T>>;
5
- type ComparableOps<C> = [C] extends [never] ? Record<never, never> : {
6
- _gt?: C;
7
- _lt?: C;
8
- _gte?: C;
9
- _lte?: C;
10
- };
11
- type StringOps<S> = [S] extends [never] ? Record<never, never> : {
12
- _like?: string;
13
- _ilike?: string;
14
- _similar?: string;
15
- _nsimilar?: string;
16
- _regex?: string;
17
- _nregex?: string;
18
- _iregex?: string;
19
- _niregex?: string;
20
- };
21
- export type HasuraOperatorFor<T> = {
22
- _eq?: T;
23
- _neq?: T;
24
- _in?: InOf<T>;
25
- _nin?: InOf<T>;
26
- _isNull?: boolean;
27
- } & ComparableOps<ComparableOf<T>> & StringOps<StringOf<T>>;
28
- export type HasuraOperator = HasuraOperatorFor<any>;
29
- export type HasuraFilterObject = HasuraFilterObjectLogical | HasuraFilterObjectField;
30
- export type HasuraFilterObjectLogical = {
31
- _and: HasuraFilterObject[];
32
- } | {
33
- _or: HasuraFilterObject[];
34
- } | {
35
- _not: HasuraFilterObject;
36
- };
37
- type HasuraFilterObjectLogicalPartial = {
38
- _and?: HasuraFilterObject[];
39
- _or?: HasuraFilterObject[];
40
- _not?: HasuraFilterObject;
41
- };
42
- export type HasuraFilterObjectField = HasuraFilterObjectLogicalPartial & {
43
- [field: string]: HasuraFilterObjectFieldValue;
44
- };
45
- export type HasuraFilterObjectFieldValue = HasuraOperator | HasuraOperator[] | HasuraFilterObject;
46
- export declare function hasuraOperatorsAreEqual(a: HasuraOperator, b: HasuraOperator): boolean;
47
- export {};
@@ -1,5 +0,0 @@
1
- export type UnionToIntersection<U> = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
2
- export type Simplify<T> = {
3
- [K in keyof T]: T[K];
4
- } & {};
5
- export type EmptyObject = Record<never, never>;