rawsql-ts 0.10.8-beta → 0.11.0-beta
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 +174 -44
- package/dist/esm/index.js +30 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.min.js +16 -14
- package/dist/esm/index.min.js.map +4 -4
- package/dist/esm/src/index.js +4 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/transformers/DynamicQueryBuilder.js +155 -0
- package/dist/esm/src/transformers/DynamicQueryBuilder.js.map +1 -0
- package/dist/esm/src/transformers/PostgresJsonQueryBuilder.js +16 -12
- package/dist/esm/src/transformers/PostgresJsonQueryBuilder.js.map +1 -1
- package/dist/esm/src/transformers/SqlFormatter.js +1 -2
- package/dist/esm/src/transformers/SqlFormatter.js.map +1 -1
- package/dist/esm/src/transformers/TypeTransformationPostProcessor.js +342 -0
- package/dist/esm/src/transformers/TypeTransformationPostProcessor.js.map +1 -0
- package/dist/esm/src/transformers/UnifiedJsonMapping.js +59 -0
- package/dist/esm/src/transformers/UnifiedJsonMapping.js.map +1 -0
- package/dist/esm/src/utils/JsonSchemaValidator.js +211 -0
- package/dist/esm/src/utils/JsonSchemaValidator.js.map +1 -0
- package/dist/esm/tsconfig.browser.tsbuildinfo +1 -1
- package/dist/esm/types/src/index.d.ts +4 -0
- package/dist/esm/types/src/transformers/DynamicQueryBuilder.d.ts +108 -0
- package/dist/esm/types/src/transformers/PostgresJsonQueryBuilder.d.ts +3 -1
- package/dist/esm/types/src/transformers/SqlFormatter.d.ts +2 -3
- package/dist/esm/types/src/transformers/TypeTransformationPostProcessor.d.ts +108 -0
- package/dist/esm/types/src/transformers/UnifiedJsonMapping.d.ts +54 -0
- package/dist/esm/types/src/utils/JsonSchemaValidator.d.ts +81 -0
- package/dist/index.min.js +16 -14
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/transformers/DynamicQueryBuilder.d.ts +108 -0
- package/dist/src/transformers/DynamicQueryBuilder.js +159 -0
- package/dist/src/transformers/DynamicQueryBuilder.js.map +1 -0
- package/dist/src/transformers/PostgresJsonQueryBuilder.d.ts +3 -1
- package/dist/src/transformers/PostgresJsonQueryBuilder.js +16 -12
- package/dist/src/transformers/PostgresJsonQueryBuilder.js.map +1 -1
- package/dist/src/transformers/SqlFormatter.d.ts +2 -3
- package/dist/src/transformers/SqlFormatter.js +1 -2
- package/dist/src/transformers/SqlFormatter.js.map +1 -1
- package/dist/src/transformers/TypeTransformationPostProcessor.d.ts +108 -0
- package/dist/src/transformers/TypeTransformationPostProcessor.js +351 -0
- package/dist/src/transformers/TypeTransformationPostProcessor.js.map +1 -0
- package/dist/src/transformers/UnifiedJsonMapping.d.ts +54 -0
- package/dist/src/transformers/UnifiedJsonMapping.js +62 -0
- package/dist/src/transformers/UnifiedJsonMapping.js.map +1 -0
- package/dist/src/utils/JsonSchemaValidator.d.ts +81 -0
- package/dist/src/utils/JsonSchemaValidator.js +215 -0
- package/dist/src/utils/JsonSchemaValidator.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -4
package/dist/esm/src/index.js
CHANGED
|
@@ -15,12 +15,16 @@ export * from './transformers/SelectValueCollector';
|
|
|
15
15
|
export * from './transformers/SelectableColumnCollector';
|
|
16
16
|
export * from './transformers/TableColumnResolver';
|
|
17
17
|
export * from './transformers/TableSourceCollector';
|
|
18
|
+
export * from './transformers/UnifiedJsonMapping';
|
|
18
19
|
export * from './transformers/UpstreamSelectQueryFinder';
|
|
20
|
+
export * from './transformers/TypeTransformationPostProcessor';
|
|
19
21
|
export * from './transformers/SchemaCollector';
|
|
20
22
|
export * from './transformers/SqlParamInjector';
|
|
21
23
|
export * from './transformers/SqlSortInjector';
|
|
22
24
|
export * from './transformers/SqlPaginationInjector';
|
|
25
|
+
export * from './transformers/DynamicQueryBuilder';
|
|
23
26
|
export * from './utils/SqlSchemaValidator';
|
|
27
|
+
export * from './utils/JsonSchemaValidator';
|
|
24
28
|
export * from './utils/SchemaManager';
|
|
25
29
|
// Add more exports here if you want to expose additional public API
|
|
26
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAErC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yCAAyC,CAAC;AACxD,cAAc,6BAA6B,CAAC,CAAC,0BAA0B;AACvE,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAErC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yCAAyC,CAAC;AACxD,cAAc,6BAA6B,CAAC,CAAC,0BAA0B;AACvE,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,0CAA0C,CAAC;AACzD,cAAc,gDAAgD,CAAC;AAE/D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,oEAAoE"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { SelectQueryParser } from "../parsers/SelectQueryParser";
|
|
2
|
+
import { SqlParamInjector } from "./SqlParamInjector";
|
|
3
|
+
import { SqlSortInjector } from "./SqlSortInjector";
|
|
4
|
+
import { SqlPaginationInjector } from "./SqlPaginationInjector";
|
|
5
|
+
import { PostgresJsonQueryBuilder } from "./PostgresJsonQueryBuilder";
|
|
6
|
+
import { QueryBuilder } from "./QueryBuilder";
|
|
7
|
+
/**
|
|
8
|
+
* DynamicQueryBuilder provides pure JavaScript SQL query building capabilities.
|
|
9
|
+
* It combines SQL parsing with dynamic condition injection (filtering, sorting, pagination, serialization).
|
|
10
|
+
*
|
|
11
|
+
* This class is framework-agnostic and does not perform any file I/O operations.
|
|
12
|
+
* It only works with SQL content provided as strings.
|
|
13
|
+
*
|
|
14
|
+
* Key features:
|
|
15
|
+
* - Pure JavaScript/TypeScript - no file system dependencies
|
|
16
|
+
* - Framework-agnostic - can be used with any database framework
|
|
17
|
+
* - Composable - combines multiple injectors in the correct order
|
|
18
|
+
* - Type-safe - provides TypeScript types for all options
|
|
19
|
+
* - Testable - easy to unit test without mocking file system
|
|
20
|
+
*/
|
|
21
|
+
export class DynamicQueryBuilder {
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new DynamicQueryBuilder instance
|
|
24
|
+
* @param tableColumnResolver Optional function to resolve table columns for wildcard queries
|
|
25
|
+
*/
|
|
26
|
+
constructor(tableColumnResolver) {
|
|
27
|
+
this.tableColumnResolver = tableColumnResolver;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Builds a SelectQuery from SQL content with dynamic conditions.
|
|
31
|
+
* This is a pure function that does not perform any I/O operations.
|
|
32
|
+
* * @param sqlContent Raw SQL string to parse and modify
|
|
33
|
+
* @param options Dynamic conditions to apply (filter, sort, paging, serialize)
|
|
34
|
+
* @returns Modified SelectQuery with all dynamic conditions applied
|
|
35
|
+
* * @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const builder = new DynamicQueryBuilder();
|
|
38
|
+
* const query = builder.buildQuery(
|
|
39
|
+
* 'SELECT id, name FROM users WHERE active = true',
|
|
40
|
+
* {
|
|
41
|
+
* filter: { status: 'premium' },
|
|
42
|
+
* sort: { created_at: { desc: true } },
|
|
43
|
+
* paging: { page: 2, pageSize: 10 },
|
|
44
|
+
* serialize: { rootName: 'user', rootEntity: { id: 'user', name: 'User', columns: { id: 'id', name: 'name' } }, nestedEntities: [] }
|
|
45
|
+
* }
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
buildQuery(sqlContent, options = {}) {
|
|
50
|
+
// Parse the base SQL
|
|
51
|
+
let parsedQuery;
|
|
52
|
+
try {
|
|
53
|
+
parsedQuery = SelectQueryParser.parse(sqlContent);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new Error(`Failed to parse SQL: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
57
|
+
}
|
|
58
|
+
// Apply dynamic modifications in the correct order
|
|
59
|
+
let modifiedQuery = parsedQuery;
|
|
60
|
+
// 1. Apply filtering first (most selective, should reduce data early)
|
|
61
|
+
if (options.filter && Object.keys(options.filter).length > 0) {
|
|
62
|
+
const paramInjector = new SqlParamInjector(this.tableColumnResolver);
|
|
63
|
+
// Ensure we have a SimpleSelectQuery for the injector
|
|
64
|
+
const simpleQuery = QueryBuilder.buildSimpleQuery(modifiedQuery);
|
|
65
|
+
modifiedQuery = paramInjector.inject(simpleQuery, options.filter);
|
|
66
|
+
}
|
|
67
|
+
// 2. Apply sorting second (after filtering to sort smaller dataset)
|
|
68
|
+
if (options.sort && Object.keys(options.sort).length > 0) {
|
|
69
|
+
const sortInjector = new SqlSortInjector(this.tableColumnResolver);
|
|
70
|
+
// Ensure we have a SimpleSelectQuery for the injector
|
|
71
|
+
const simpleQuery = QueryBuilder.buildSimpleQuery(modifiedQuery);
|
|
72
|
+
modifiedQuery = sortInjector.inject(simpleQuery, options.sort);
|
|
73
|
+
} // 3. Apply pagination third (after filtering and sorting)
|
|
74
|
+
if (options.paging) {
|
|
75
|
+
const { page = 1, pageSize } = options.paging;
|
|
76
|
+
if (pageSize !== undefined) {
|
|
77
|
+
const paginationInjector = new SqlPaginationInjector();
|
|
78
|
+
const paginationOptions = { page, pageSize };
|
|
79
|
+
// Ensure we have a SimpleSelectQuery for the injector
|
|
80
|
+
const simpleQuery = QueryBuilder.buildSimpleQuery(modifiedQuery);
|
|
81
|
+
modifiedQuery = paginationInjector.inject(simpleQuery, paginationOptions);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// 4. Apply serialization last (transform the final query structure to JSON)
|
|
85
|
+
// Note: boolean values are handled at RawSqlClient level for auto-loading
|
|
86
|
+
if (options.serialize && typeof options.serialize === 'object') {
|
|
87
|
+
const jsonBuilder = new PostgresJsonQueryBuilder();
|
|
88
|
+
// Ensure we have a SimpleSelectQuery for the JSON builder
|
|
89
|
+
const simpleQuery = QueryBuilder.buildSimpleQuery(modifiedQuery);
|
|
90
|
+
modifiedQuery = jsonBuilder.buildJsonQuery(simpleQuery, options.serialize);
|
|
91
|
+
}
|
|
92
|
+
return modifiedQuery;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Builds a SelectQuery with only filtering applied.
|
|
96
|
+
* Convenience method for when you only need dynamic WHERE conditions.
|
|
97
|
+
*
|
|
98
|
+
* @param sqlContent Raw SQL string to parse and modify
|
|
99
|
+
* @param filter Filter conditions to apply
|
|
100
|
+
* @returns Modified SelectQuery with filter conditions applied
|
|
101
|
+
*/
|
|
102
|
+
buildFilteredQuery(sqlContent, filter) {
|
|
103
|
+
return this.buildQuery(sqlContent, { filter });
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Builds a SelectQuery with only sorting applied.
|
|
107
|
+
* Convenience method for when you only need dynamic ORDER BY clauses.
|
|
108
|
+
*
|
|
109
|
+
* @param sqlContent Raw SQL string to parse and modify
|
|
110
|
+
* @param sort Sort conditions to apply
|
|
111
|
+
* @returns Modified SelectQuery with sort conditions applied
|
|
112
|
+
*/
|
|
113
|
+
buildSortedQuery(sqlContent, sort) {
|
|
114
|
+
return this.buildQuery(sqlContent, { sort });
|
|
115
|
+
} /**
|
|
116
|
+
* Builds a SelectQuery with only pagination applied.
|
|
117
|
+
* Convenience method for when you only need LIMIT/OFFSET clauses.
|
|
118
|
+
*
|
|
119
|
+
* @param sqlContent Raw SQL string to parse and modify
|
|
120
|
+
* @param paging Pagination options to apply
|
|
121
|
+
* @returns Modified SelectQuery with pagination applied
|
|
122
|
+
*/
|
|
123
|
+
buildPaginatedQuery(sqlContent, paging) {
|
|
124
|
+
return this.buildQuery(sqlContent, { paging });
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Builds a SelectQuery with only JSON serialization applied.
|
|
128
|
+
* Convenience method for when you only need hierarchical JSON transformation.
|
|
129
|
+
*
|
|
130
|
+
* @param sqlContent Raw SQL string to parse and modify
|
|
131
|
+
* @param serialize JSON mapping configuration to apply
|
|
132
|
+
* @returns Modified SelectQuery with JSON serialization applied
|
|
133
|
+
*/
|
|
134
|
+
buildSerializedQuery(sqlContent, serialize) {
|
|
135
|
+
return this.buildQuery(sqlContent, { serialize });
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Validates SQL content by attempting to parse it.
|
|
139
|
+
* Useful for testing SQL validity without applying any modifications.
|
|
140
|
+
*
|
|
141
|
+
* @param sqlContent Raw SQL string to validate
|
|
142
|
+
* @returns true if SQL is valid, throws error if invalid
|
|
143
|
+
* @throws Error if SQL cannot be parsed
|
|
144
|
+
*/
|
|
145
|
+
validateSql(sqlContent) {
|
|
146
|
+
try {
|
|
147
|
+
SelectQueryParser.parse(sqlContent);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
throw new Error(`Invalid SQL: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=DynamicQueryBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicQueryBuilder.js","sourceRoot":"","sources":["../../../../src/transformers/DynamicQueryBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAqB,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAe,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAoB9C;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,mBAAmB;IAE5B;;;OAGG;IACH,YAAY,mBAAqD;QAC7D,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACnD,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,UAAkB,EAAE,UAA6B,EAAE;QAC1D,qBAAqB;QACrB,IAAI,WAA8B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B,CAAC,UAAkB,EAAE,SAAsB;QAC3D,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACH,WAAW,CAAC,UAAkB;QAC1B,IAAI,CAAC;YACD,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACpC,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,gBAAgB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;QAChG,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -4,6 +4,7 @@ import { IdentifierString, ColumnReference, FunctionCall, ValueList, LiteralValu
|
|
|
4
4
|
import { SelectValueCollector } from "./SelectValueCollector";
|
|
5
5
|
import { PostgresObjectEntityCteBuilder } from './PostgresObjectEntityCteBuilder';
|
|
6
6
|
import { PostgresArrayEntityCteBuilder } from './PostgresArrayEntityCteBuilder';
|
|
7
|
+
import { QueryBuilder } from './QueryBuilder';
|
|
7
8
|
/**
|
|
8
9
|
* PostgreSQL JSON query builder that transforms SimpleSelectQuery into queries
|
|
9
10
|
* that return JSON arrays or single JSON objects using PostgreSQL JSON functions.
|
|
@@ -24,10 +25,11 @@ export class PostgresJsonQueryBuilder {
|
|
|
24
25
|
const collector = new SelectValueCollector();
|
|
25
26
|
const selectedValues = collector.collect(query);
|
|
26
27
|
// sv.name is the alias or derived name
|
|
27
|
-
const availableColumns = new Set(selectedValues.map(sv => sv.name));
|
|
28
|
-
// Check root entity columns
|
|
28
|
+
const availableColumns = new Set(selectedValues.map(sv => sv.name)); // Check root entity columns
|
|
29
29
|
for (const jsonKey in mapping.rootEntity.columns) {
|
|
30
|
-
const
|
|
30
|
+
const columnDef = mapping.rootEntity.columns[jsonKey];
|
|
31
|
+
// Handle both string and object formats
|
|
32
|
+
const sourceColumn = typeof columnDef === 'string' ? columnDef : columnDef.column;
|
|
31
33
|
if (!availableColumns.has(sourceColumn)) {
|
|
32
34
|
throw new Error(`Validation Error: Column "${sourceColumn}" for JSON key "${jsonKey}" in root entity "${mapping.rootEntity.name}" not found in the query's select list.`);
|
|
33
35
|
}
|
|
@@ -47,7 +49,9 @@ export class PostgresJsonQueryBuilder {
|
|
|
47
49
|
throw new Error(`Validation Error: Parent entity with ID "${entity.parentId}" for nested entity "${entity.name}" (ID: ${entity.id}) not found.`);
|
|
48
50
|
}
|
|
49
51
|
for (const jsonKey in entity.columns) {
|
|
50
|
-
const
|
|
52
|
+
const columnDef = entity.columns[jsonKey];
|
|
53
|
+
// Handle both string and object formats
|
|
54
|
+
const sourceColumn = typeof columnDef === 'string' ? columnDef : columnDef.column;
|
|
51
55
|
if (!availableColumns.has(sourceColumn)) {
|
|
52
56
|
throw new Error(`Validation Error: Column "${sourceColumn}" for JSON key "${jsonKey}" in nested entity "${entity.name}" (ID: ${entity.id}) not found in the query's select list.`);
|
|
53
57
|
}
|
|
@@ -73,14 +77,12 @@ export class PostgresJsonQueryBuilder {
|
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Build JSON query from original query and mapping configuration.
|
|
78
|
-
* @param originalQuery Original query to transform
|
|
79
|
-
* @param mapping JSON mapping configuration
|
|
80
|
-
* @returns Transformed query with JSON aggregation
|
|
81
|
-
*/
|
|
82
80
|
buildJsonQuery(originalQuery, mapping) {
|
|
83
|
-
|
|
81
|
+
// Convert any SelectQuery to SimpleSelectQuery using QueryBuilder
|
|
82
|
+
const simpleQuery = originalQuery instanceof SimpleSelectQuery
|
|
83
|
+
? originalQuery
|
|
84
|
+
: QueryBuilder.buildSimpleQuery(originalQuery);
|
|
85
|
+
return this.buildJsonWithCteStrategy(simpleQuery, mapping);
|
|
84
86
|
}
|
|
85
87
|
/**
|
|
86
88
|
* Build JSON query from original query and mapping configuration.
|
|
@@ -199,7 +201,9 @@ export class PostgresJsonQueryBuilder {
|
|
|
199
201
|
buildEntityJsonObject(entity, sourceAlias, nestedEntities, allEntities, useJsonb = false) {
|
|
200
202
|
const jsonBuildFunction = useJsonb ? "jsonb_build_object" : "json_build_object";
|
|
201
203
|
const args = []; // Add the entity's own columns
|
|
202
|
-
Object.entries(entity.columns).forEach(([jsonKey,
|
|
204
|
+
Object.entries(entity.columns).forEach(([jsonKey, columnDef]) => {
|
|
205
|
+
// Handle both string and object formats
|
|
206
|
+
const sqlColumn = typeof columnDef === 'string' ? columnDef : columnDef.column;
|
|
203
207
|
args.push(new LiteralValue(jsonKey));
|
|
204
208
|
args.push(new ColumnReference(null, new IdentifierString(sqlColumn)));
|
|
205
209
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresJsonQueryBuilder.js","sourceRoot":"","sources":["../../../../src/transformers/PostgresJsonQueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAiB,UAAU,EAAkB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnM,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAkB,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAA0E,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AACxO,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,8BAA8B,EAAqB,MAAM,kCAAkC,CAAC;AACrG,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AA0BhF;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAG6B;QAC1D,IAAI,CAAC,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,s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AAI,eAAe,CAAC,IAAI,EAAE,IAAI,gBAAgB,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACzF,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC,iBAAiB,CAAC,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/F,CAAC;CACJ"}
|
|
@@ -15,8 +15,7 @@ export class SqlFormatter {
|
|
|
15
15
|
const parserOptions = Object.assign(Object.assign({}, presetConfig), { identifierEscape: (_a = options.identifierEscape) !== null && _a !== void 0 ? _a : presetConfig === null || presetConfig === void 0 ? void 0 : presetConfig.identifierEscape, parameterSymbol: (_b = options.parameterSymbol) !== null && _b !== void 0 ? _b : presetConfig === null || presetConfig === void 0 ? void 0 : presetConfig.parameterSymbol, parameterStyle: (_c = options.parameterStyle) !== null && _c !== void 0 ? _c : presetConfig === null || presetConfig === void 0 ? void 0 : presetConfig.parameterStyle });
|
|
16
16
|
this.parser = new SqlPrintTokenParser(parserOptions);
|
|
17
17
|
this.printer = new SqlPrinter(options);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
18
|
+
} /**
|
|
20
19
|
* Formats a SQL query string with the given parameters.
|
|
21
20
|
* @param sqlText The SQL query string to format.
|
|
22
21
|
* @param parameters A dictionary of parameters to replace in the query.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlFormatter.js","sourceRoot":"","sources":["../../../../src/transformers/SqlFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAmB,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAkC,MAAM,cAAc,CAAC;AAK1E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC;AAGnF;;GAEG;AAC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AO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1E,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,iCAAiC;QAC3F,CAAC;QAED,MAAM,aAAa,mCACZ,YAAY,KACf,gBAAgB,EAAE,MAAA,OAAO,CAAC,gBAAgB,mCAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,gBAAgB,EAC5E,eAAe,EAAE,MAAA,OAAO,CAAC,eAAe,mCAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,eAAe,EACzE,cAAc,EAAE,MAAA,OAAO,CAAC,cAAc,mCAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,cAAc,GACzE,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,CAAC,aAAa,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAI;;;;;OAKF;IACH,MAAM,CAAC,GAAiB;QACpB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC;CACJ"}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-processor for transforming database values to appropriate TypeScript types
|
|
3
|
+
* after JSON serialization from PostgreSQL
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Applies type transformations to JSON results from PostgreSQL
|
|
7
|
+
*/
|
|
8
|
+
export class TypeTransformationPostProcessor {
|
|
9
|
+
constructor(config = {}) {
|
|
10
|
+
this.config = Object.assign({ enableValueBasedDetection: true, strictDateDetection: false }, config);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Transform a single result object
|
|
14
|
+
* @param result The result object from PostgreSQL JSON query
|
|
15
|
+
* @returns Transformed result with proper TypeScript types
|
|
16
|
+
*/
|
|
17
|
+
transformResult(result) {
|
|
18
|
+
if (result === null || result === undefined) {
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(result)) {
|
|
22
|
+
return result.map(item => this.transformSingleObject(item));
|
|
23
|
+
}
|
|
24
|
+
return this.transformSingleObject(result);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Transform a single object recursively
|
|
28
|
+
*/
|
|
29
|
+
transformSingleObject(obj) {
|
|
30
|
+
var _a;
|
|
31
|
+
if (obj === null || obj === undefined || typeof obj !== 'object') {
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(obj)) {
|
|
35
|
+
return obj.map(item => this.transformSingleObject(item));
|
|
36
|
+
}
|
|
37
|
+
const transformed = {};
|
|
38
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
39
|
+
if (value === null || value === undefined) {
|
|
40
|
+
transformed[key] = value;
|
|
41
|
+
continue;
|
|
42
|
+
} // Check for column-specific transformation first (takes precedence)
|
|
43
|
+
const columnTransform = (_a = this.config.columnTransformations) === null || _a === void 0 ? void 0 : _a[key];
|
|
44
|
+
if (columnTransform) {
|
|
45
|
+
transformed[key] = this.applyTransformation(value, columnTransform);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
// Only apply value-based detection if enabled and no column mapping exists
|
|
49
|
+
if (this.config.enableValueBasedDetection) {
|
|
50
|
+
const detectedTransform = this.detectValueBasedTransformation(value);
|
|
51
|
+
if (detectedTransform) {
|
|
52
|
+
transformed[key] = this.applyTransformation(value, detectedTransform);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Apply global transformations based on SQL type (if available)
|
|
57
|
+
const globalTransform = this.config.globalTransformations &&
|
|
58
|
+
this.getGlobalTransformationForValue(value);
|
|
59
|
+
if (globalTransform) {
|
|
60
|
+
transformed[key] = this.applyTransformation(value, globalTransform);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// Recursively transform nested objects
|
|
64
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
65
|
+
transformed[key] = this.transformSingleObject(value);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (Array.isArray(value)) {
|
|
69
|
+
transformed[key] = value.map(item => typeof item === 'object' ? this.transformSingleObject(item) : item);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
// No transformation needed
|
|
73
|
+
transformed[key] = value;
|
|
74
|
+
}
|
|
75
|
+
return transformed;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Detect value type and create appropriate transformation based on value characteristics
|
|
79
|
+
* This is the core value-based detection logic
|
|
80
|
+
*/
|
|
81
|
+
detectValueBasedTransformation(value) {
|
|
82
|
+
// Date string detection
|
|
83
|
+
if (typeof value === 'string' && this.isDateString(value)) {
|
|
84
|
+
return {
|
|
85
|
+
sourceType: 'TIMESTAMP',
|
|
86
|
+
targetType: 'Date',
|
|
87
|
+
handleNull: true,
|
|
88
|
+
validator: (v) => typeof v === 'string' && !isNaN(Date.parse(v))
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// BigInt detection (number > MAX_SAFE_INTEGER)
|
|
92
|
+
if (typeof value === 'number' && !Number.isSafeInteger(value)) {
|
|
93
|
+
return {
|
|
94
|
+
sourceType: 'BIGINT',
|
|
95
|
+
targetType: 'bigint',
|
|
96
|
+
handleNull: true,
|
|
97
|
+
validator: (v) => {
|
|
98
|
+
try {
|
|
99
|
+
BigInt(v);
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
catch (_a) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Large string number detection (potential BIGINT)
|
|
109
|
+
if (typeof value === 'string' && /^\d{16,}$/.test(value)) {
|
|
110
|
+
return {
|
|
111
|
+
sourceType: 'BIGINT',
|
|
112
|
+
targetType: 'bigint',
|
|
113
|
+
handleNull: true,
|
|
114
|
+
validator: (v) => {
|
|
115
|
+
try {
|
|
116
|
+
BigInt(v);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
catch (_a) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get global transformation for a specific value (if any match)
|
|
129
|
+
* This is separate from value-based detection and relies on configured global rules
|
|
130
|
+
*/
|
|
131
|
+
getGlobalTransformationForValue(value) {
|
|
132
|
+
if (!this.config.globalTransformations) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
// This could be extended to match values against configured global rules
|
|
136
|
+
// For now, it's a placeholder for future SQL-type-based global transformations
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Use detectValueBasedTransformation instead
|
|
141
|
+
* Detect value type and get appropriate global transformation
|
|
142
|
+
*/
|
|
143
|
+
detectAndGetGlobalTransformation(value) {
|
|
144
|
+
return this.detectValueBasedTransformation(value);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Check if string is a valid date string
|
|
148
|
+
* Supports both strict (ISO 8601 with T separator) and loose detection
|
|
149
|
+
*/
|
|
150
|
+
isDateString(value) {
|
|
151
|
+
if (this.config.strictDateDetection) {
|
|
152
|
+
// Strict: Only ISO 8601 with T separator (safer for user input)
|
|
153
|
+
const strictIsoPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?(?:Z|[+-]\d{2}:\d{2})?$/;
|
|
154
|
+
if (!strictIsoPattern.test(value)) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// Loose: ISO 8601 date pattern (includes date-only strings)
|
|
160
|
+
const isoDatePattern = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d{3})?(?:Z|[+-]\d{2}:\d{2})?)?$/;
|
|
161
|
+
if (!isoDatePattern.test(value)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const date = new Date(value);
|
|
166
|
+
return !isNaN(date.getTime());
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Apply a specific transformation to a value
|
|
170
|
+
*/
|
|
171
|
+
applyTransformation(value, transformation) {
|
|
172
|
+
var _a;
|
|
173
|
+
// Handle null values
|
|
174
|
+
if (value === null || value === undefined) {
|
|
175
|
+
return transformation.handleNull !== false ? value : null;
|
|
176
|
+
}
|
|
177
|
+
// Validate value if validator is provided
|
|
178
|
+
if (transformation.validator && !transformation.validator(value)) {
|
|
179
|
+
console.warn(`TypeTransformationPostProcessor: Value validation failed for ${value}`);
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
switch (transformation.targetType) {
|
|
184
|
+
case 'Date':
|
|
185
|
+
return new Date(value);
|
|
186
|
+
case 'bigint':
|
|
187
|
+
// Handle both string and number inputs for BIGINT
|
|
188
|
+
// For scientific notation numbers, convert to integer first
|
|
189
|
+
if (typeof value === 'number') {
|
|
190
|
+
// Convert scientific notation to integer string
|
|
191
|
+
const integerValue = Math.trunc(value);
|
|
192
|
+
return BigInt(integerValue.toString());
|
|
193
|
+
}
|
|
194
|
+
return BigInt(value);
|
|
195
|
+
case 'string':
|
|
196
|
+
return value.toString();
|
|
197
|
+
case 'number':
|
|
198
|
+
return typeof value === 'string' ? parseFloat(value) : Number(value);
|
|
199
|
+
case 'object':
|
|
200
|
+
return typeof value === 'string' ? JSON.parse(value) : value;
|
|
201
|
+
case 'custom':
|
|
202
|
+
if (transformation.customTransformer &&
|
|
203
|
+
((_a = this.config.customTransformers) === null || _a === void 0 ? void 0 : _a[transformation.customTransformer])) {
|
|
204
|
+
return this.config.customTransformers[transformation.customTransformer](value);
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
default:
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
console.warn(`TypeTransformationPostProcessor: Transformation failed for ${value}:`, error);
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Create a default configuration for common PostgreSQL types
|
|
219
|
+
* Enables value-based detection with loose date detection by default
|
|
220
|
+
*/
|
|
221
|
+
static createDefaultConfig() {
|
|
222
|
+
return {
|
|
223
|
+
enableValueBasedDetection: true,
|
|
224
|
+
strictDateDetection: false,
|
|
225
|
+
globalTransformations: {
|
|
226
|
+
'DATE': {
|
|
227
|
+
sourceType: 'DATE',
|
|
228
|
+
targetType: 'Date',
|
|
229
|
+
handleNull: true,
|
|
230
|
+
validator: (value) => typeof value === 'string' && !isNaN(Date.parse(value))
|
|
231
|
+
},
|
|
232
|
+
'TIMESTAMP': {
|
|
233
|
+
sourceType: 'TIMESTAMP',
|
|
234
|
+
targetType: 'Date',
|
|
235
|
+
handleNull: true,
|
|
236
|
+
validator: (value) => typeof value === 'string' && !isNaN(Date.parse(value))
|
|
237
|
+
},
|
|
238
|
+
'BIGINT': {
|
|
239
|
+
sourceType: 'BIGINT',
|
|
240
|
+
targetType: 'bigint',
|
|
241
|
+
handleNull: true,
|
|
242
|
+
validator: (value) => {
|
|
243
|
+
try {
|
|
244
|
+
BigInt(value);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
catch (_a) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Create a safe configuration for handling user input
|
|
257
|
+
* Disables value-based detection and uses strict date detection
|
|
258
|
+
*/
|
|
259
|
+
static createSafeConfig(columnMappings) {
|
|
260
|
+
return {
|
|
261
|
+
enableValueBasedDetection: false,
|
|
262
|
+
strictDateDetection: true,
|
|
263
|
+
columnTransformations: columnMappings || {},
|
|
264
|
+
globalTransformations: {
|
|
265
|
+
'DATE': {
|
|
266
|
+
sourceType: 'DATE',
|
|
267
|
+
targetType: 'Date',
|
|
268
|
+
handleNull: true,
|
|
269
|
+
validator: (value) => typeof value === 'string' && !isNaN(Date.parse(value))
|
|
270
|
+
},
|
|
271
|
+
'TIMESTAMP': {
|
|
272
|
+
sourceType: 'TIMESTAMP',
|
|
273
|
+
targetType: 'Date',
|
|
274
|
+
handleNull: true,
|
|
275
|
+
validator: (value) => typeof value === 'string' && !isNaN(Date.parse(value))
|
|
276
|
+
},
|
|
277
|
+
'BIGINT': {
|
|
278
|
+
sourceType: 'BIGINT',
|
|
279
|
+
targetType: 'bigint',
|
|
280
|
+
handleNull: true,
|
|
281
|
+
validator: (value) => {
|
|
282
|
+
try {
|
|
283
|
+
BigInt(value);
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
catch (_a) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Convenience function to create and apply transformations
|
|
297
|
+
*/
|
|
298
|
+
export function transformDatabaseResult(result, config) {
|
|
299
|
+
const processor = new TypeTransformationPostProcessor(config || TypeTransformationPostProcessor.createDefaultConfig());
|
|
300
|
+
return processor.transformResult(result);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Type-safe transformation helpers
|
|
304
|
+
*/
|
|
305
|
+
export const TypeTransformers = {
|
|
306
|
+
/**
|
|
307
|
+
* Transform date string to Date object
|
|
308
|
+
*/
|
|
309
|
+
toDate: (value) => {
|
|
310
|
+
if (value === null || value === undefined)
|
|
311
|
+
return null;
|
|
312
|
+
const date = new Date(value);
|
|
313
|
+
return isNaN(date.getTime()) ? null : date;
|
|
314
|
+
},
|
|
315
|
+
/**
|
|
316
|
+
* Transform numeric string to BigInt
|
|
317
|
+
*/
|
|
318
|
+
toBigInt: (value) => {
|
|
319
|
+
if (value === null || value === undefined)
|
|
320
|
+
return null;
|
|
321
|
+
try {
|
|
322
|
+
return BigInt(value);
|
|
323
|
+
}
|
|
324
|
+
catch (_a) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
/**
|
|
329
|
+
* Transform JSON string to object
|
|
330
|
+
*/
|
|
331
|
+
toObject: (value) => {
|
|
332
|
+
if (value === null || value === undefined)
|
|
333
|
+
return null;
|
|
334
|
+
try {
|
|
335
|
+
return JSON.parse(value);
|
|
336
|
+
}
|
|
337
|
+
catch (_a) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
//# sourceMappingURL=TypeTransformationPostProcessor.js.map
|