@uql/core 3.1.1 → 3.1.2
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/CHANGELOG.md +134 -187
- package/package.json +31 -26
- package/dist/CHANGELOG.md +0 -186
- package/dist/package.json +0 -131
- package/src/@types/index.d.ts +0 -1
- package/src/@types/jest.d.ts +0 -6
- package/src/browser/http/bus.spec.ts +0 -22
- package/src/browser/http/bus.ts +0 -17
- package/src/browser/http/http.spec.ts +0 -70
- package/src/browser/http/http.ts +0 -55
- package/src/browser/http/index.ts +0 -2
- package/src/browser/index.ts +0 -4
- package/src/browser/options.spec.ts +0 -37
- package/src/browser/options.ts +0 -18
- package/src/browser/querier/genericClientRepository.spec.ts +0 -105
- package/src/browser/querier/genericClientRepository.ts +0 -49
- package/src/browser/querier/httpQuerier.ts +0 -82
- package/src/browser/querier/index.ts +0 -3
- package/src/browser/querier/querier.util.spec.ts +0 -35
- package/src/browser/querier/querier.util.ts +0 -18
- package/src/browser/type/clientQuerier.ts +0 -45
- package/src/browser/type/clientQuerierPool.ts +0 -5
- package/src/browser/type/clientRepository.ts +0 -22
- package/src/browser/type/index.ts +0 -4
- package/src/browser/type/request.ts +0 -25
- package/src/dialect/abstractDialect.ts +0 -28
- package/src/dialect/abstractSqlDialect-spec.ts +0 -1309
- package/src/dialect/abstractSqlDialect.ts +0 -805
- package/src/dialect/index.ts +0 -3
- package/src/dialect/namingStrategy.spec.ts +0 -52
- package/src/dialect/queryContext.ts +0 -69
- package/src/entity/decorator/definition.spec.ts +0 -736
- package/src/entity/decorator/definition.ts +0 -265
- package/src/entity/decorator/entity.ts +0 -8
- package/src/entity/decorator/field.ts +0 -9
- package/src/entity/decorator/id.ts +0 -9
- package/src/entity/decorator/index.ts +0 -5
- package/src/entity/decorator/relation.spec.ts +0 -41
- package/src/entity/decorator/relation.ts +0 -34
- package/src/entity/index.ts +0 -1
- package/src/express/@types/express.d.ts +0 -8
- package/src/express/@types/index.d.ts +0 -1
- package/src/express/index.ts +0 -2
- package/src/express/querierMiddleware.ts +0 -217
- package/src/express/query.util.spec.ts +0 -40
- package/src/express/query.util.ts +0 -21
- package/src/index.ts +0 -9
- package/src/maria/index.ts +0 -3
- package/src/maria/mariaDialect.spec.ts +0 -207
- package/src/maria/mariaDialect.ts +0 -42
- package/src/maria/mariaQuerierPool.test.ts +0 -23
- package/src/maria/mariadbQuerier.test.ts +0 -23
- package/src/maria/mariadbQuerier.ts +0 -45
- package/src/maria/mariadbQuerierPool.ts +0 -21
- package/src/migrate/cli.ts +0 -301
- package/src/migrate/generator/index.ts +0 -4
- package/src/migrate/generator/mongoSchemaGenerator.spec.ts +0 -112
- package/src/migrate/generator/mongoSchemaGenerator.ts +0 -115
- package/src/migrate/generator/mysqlSchemaGenerator.spec.ts +0 -34
- package/src/migrate/generator/mysqlSchemaGenerator.ts +0 -92
- package/src/migrate/generator/postgresSchemaGenerator.spec.ts +0 -44
- package/src/migrate/generator/postgresSchemaGenerator.ts +0 -127
- package/src/migrate/generator/sqliteSchemaGenerator.spec.ts +0 -33
- package/src/migrate/generator/sqliteSchemaGenerator.ts +0 -81
- package/src/migrate/index.ts +0 -41
- package/src/migrate/introspection/index.ts +0 -4
- package/src/migrate/introspection/mongoIntrospector.spec.ts +0 -75
- package/src/migrate/introspection/mongoIntrospector.ts +0 -47
- package/src/migrate/introspection/mysqlIntrospector.spec.ts +0 -113
- package/src/migrate/introspection/mysqlIntrospector.ts +0 -278
- package/src/migrate/introspection/postgresIntrospector.spec.ts +0 -112
- package/src/migrate/introspection/postgresIntrospector.ts +0 -329
- package/src/migrate/introspection/sqliteIntrospector.spec.ts +0 -112
- package/src/migrate/introspection/sqliteIntrospector.ts +0 -296
- package/src/migrate/migrator-mongo.test.ts +0 -54
- package/src/migrate/migrator.spec.ts +0 -255
- package/src/migrate/migrator.test.ts +0 -94
- package/src/migrate/migrator.ts +0 -719
- package/src/migrate/namingStrategy.spec.ts +0 -22
- package/src/migrate/schemaGenerator-advanced.spec.ts +0 -138
- package/src/migrate/schemaGenerator.spec.ts +0 -190
- package/src/migrate/schemaGenerator.ts +0 -478
- package/src/migrate/storage/databaseStorage.spec.ts +0 -69
- package/src/migrate/storage/databaseStorage.ts +0 -100
- package/src/migrate/storage/index.ts +0 -2
- package/src/migrate/storage/jsonStorage.ts +0 -58
- package/src/migrate/type.ts +0 -1
- package/src/mongo/index.ts +0 -3
- package/src/mongo/mongoDialect.spec.ts +0 -251
- package/src/mongo/mongoDialect.ts +0 -238
- package/src/mongo/mongodbQuerier.test.ts +0 -45
- package/src/mongo/mongodbQuerier.ts +0 -256
- package/src/mongo/mongodbQuerierPool.test.ts +0 -25
- package/src/mongo/mongodbQuerierPool.ts +0 -24
- package/src/mysql/index.ts +0 -3
- package/src/mysql/mysql2Querier.test.ts +0 -20
- package/src/mysql/mysql2Querier.ts +0 -49
- package/src/mysql/mysql2QuerierPool.test.ts +0 -20
- package/src/mysql/mysql2QuerierPool.ts +0 -21
- package/src/mysql/mysqlDialect.spec.ts +0 -20
- package/src/mysql/mysqlDialect.ts +0 -16
- package/src/namingStrategy/defaultNamingStrategy.ts +0 -18
- package/src/namingStrategy/index.spec.ts +0 -36
- package/src/namingStrategy/index.ts +0 -2
- package/src/namingStrategy/snakeCaseNamingStrategy.ts +0 -15
- package/src/options.spec.ts +0 -41
- package/src/options.ts +0 -18
- package/src/postgres/index.ts +0 -3
- package/src/postgres/manual-types.d.ts +0 -4
- package/src/postgres/pgQuerier.test.ts +0 -25
- package/src/postgres/pgQuerier.ts +0 -45
- package/src/postgres/pgQuerierPool.test.ts +0 -28
- package/src/postgres/pgQuerierPool.ts +0 -21
- package/src/postgres/postgresDialect.spec.ts +0 -428
- package/src/postgres/postgresDialect.ts +0 -144
- package/src/querier/abstractQuerier-test.ts +0 -584
- package/src/querier/abstractQuerier.ts +0 -353
- package/src/querier/abstractQuerierPool-test.ts +0 -20
- package/src/querier/abstractQuerierPool.ts +0 -18
- package/src/querier/abstractSqlQuerier-spec.ts +0 -979
- package/src/querier/abstractSqlQuerier-test.ts +0 -21
- package/src/querier/abstractSqlQuerier.ts +0 -138
- package/src/querier/decorator/index.ts +0 -3
- package/src/querier/decorator/injectQuerier.spec.ts +0 -74
- package/src/querier/decorator/injectQuerier.ts +0 -45
- package/src/querier/decorator/serialized.spec.ts +0 -98
- package/src/querier/decorator/serialized.ts +0 -13
- package/src/querier/decorator/transactional.spec.ts +0 -240
- package/src/querier/decorator/transactional.ts +0 -56
- package/src/querier/index.ts +0 -4
- package/src/repository/genericRepository.spec.ts +0 -111
- package/src/repository/genericRepository.ts +0 -74
- package/src/repository/index.ts +0 -1
- package/src/sqlite/index.ts +0 -3
- package/src/sqlite/manual-types.d.ts +0 -4
- package/src/sqlite/sqliteDialect.spec.ts +0 -155
- package/src/sqlite/sqliteDialect.ts +0 -76
- package/src/sqlite/sqliteQuerier.spec.ts +0 -36
- package/src/sqlite/sqliteQuerier.test.ts +0 -21
- package/src/sqlite/sqliteQuerier.ts +0 -37
- package/src/sqlite/sqliteQuerierPool.test.ts +0 -12
- package/src/sqlite/sqliteQuerierPool.ts +0 -38
- package/src/test/entityMock.ts +0 -375
- package/src/test/index.ts +0 -3
- package/src/test/it.util.ts +0 -69
- package/src/test/spec.util.ts +0 -57
- package/src/type/entity.ts +0 -218
- package/src/type/index.ts +0 -9
- package/src/type/migration.ts +0 -241
- package/src/type/namingStrategy.ts +0 -17
- package/src/type/querier.ts +0 -143
- package/src/type/querierPool.ts +0 -26
- package/src/type/query.ts +0 -506
- package/src/type/repository.ts +0 -142
- package/src/type/universalQuerier.ts +0 -133
- package/src/type/utility.ts +0 -21
- package/src/util/dialect.util-extra.spec.ts +0 -96
- package/src/util/dialect.util.spec.ts +0 -23
- package/src/util/dialect.util.ts +0 -134
- package/src/util/index.ts +0 -5
- package/src/util/object.util.spec.ts +0 -29
- package/src/util/object.util.ts +0 -27
- package/src/util/raw.ts +0 -11
- package/src/util/sql.util-extra.spec.ts +0 -17
- package/src/util/sql.util.spec.ts +0 -208
- package/src/util/sql.util.ts +0 -104
- package/src/util/string.util.spec.ts +0 -46
- package/src/util/string.util.ts +0 -35
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -8
- /package/{dist/README.md → README.md} +0 -0
package/src/dialect/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { Entity, Field, Id } from '../entity/index.js';
|
|
3
|
-
import { MySqlDialect } from '../mysql/mysqlDialect.js';
|
|
4
|
-
import { SnakeCaseNamingStrategy } from '../namingStrategy/index.js';
|
|
5
|
-
import { PostgresDialect } from '../postgres/postgresDialect.js';
|
|
6
|
-
import { SqliteDialect } from '../sqlite/sqliteDialect.js';
|
|
7
|
-
|
|
8
|
-
@Entity()
|
|
9
|
-
class UserProfileDialect {
|
|
10
|
-
@Id() id?: number;
|
|
11
|
-
@Field() firstName?: string;
|
|
12
|
-
@Field() lastName?: string;
|
|
13
|
-
@Field({ name: 'explicit_name' }) explicitField?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe('Naming Strategy SQL Generation', () => {
|
|
17
|
-
describe('Postgres with SnakeCaseNamingStrategy', () => {
|
|
18
|
-
const dialect = new PostgresDialect(new SnakeCaseNamingStrategy());
|
|
19
|
-
|
|
20
|
-
it('should translate table and column names', () => {
|
|
21
|
-
const ctx = dialect.createContext();
|
|
22
|
-
dialect.insert(ctx, UserProfileDialect, { firstName: 'John', lastName: 'Doe' });
|
|
23
|
-
expect(ctx.sql).toContain('INSERT INTO "user_profile_dialect" ("first_name", "last_name")');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should respect explicit names', () => {
|
|
27
|
-
const ctx = dialect.createContext();
|
|
28
|
-
dialect.insert(ctx, UserProfileDialect, { explicitField: 'value' });
|
|
29
|
-
expect(ctx.sql).toContain('"explicit_name"');
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('MySQL with SnakeCaseNamingStrategy', () => {
|
|
34
|
-
const dialect = new MySqlDialect(new SnakeCaseNamingStrategy());
|
|
35
|
-
|
|
36
|
-
it('should translate table and column names', () => {
|
|
37
|
-
const ctx = dialect.createContext();
|
|
38
|
-
dialect.insert(ctx, UserProfileDialect, { firstName: 'John', lastName: 'Doe' });
|
|
39
|
-
expect(ctx.sql).toContain('INSERT INTO `user_profile_dialect` (`first_name`, `last_name`)');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('SQLite with SnakeCaseNamingStrategy', () => {
|
|
44
|
-
const dialect = new SqliteDialect(new SnakeCaseNamingStrategy());
|
|
45
|
-
|
|
46
|
-
it('should translate table and column names', () => {
|
|
47
|
-
const ctx = dialect.createContext();
|
|
48
|
-
dialect.insert(ctx, UserProfileDialect, { firstName: 'John', lastName: 'Doe' });
|
|
49
|
-
expect(ctx.sql).toContain('INSERT INTO `user_profile_dialect` (`first_name`, `last_name`)');
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { QueryContext, QueryDialect } from '../type/index.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* SqlQueryContext is an implementation of the QueryContext interface specifically for SQL-based dialects.
|
|
5
|
-
* It follows the "Accumulator" or "Builder" pattern to construct SQL queries and their corresponding parameters.
|
|
6
|
-
*
|
|
7
|
-
* This pattern solves the problem of building complex SQL strings while safely managing parameterized values,
|
|
8
|
-
* preventing SQL injection and handling dialect-specific parameter placeholders (e.g., '?' for MySQL, '$n' for PostgreSQL).
|
|
9
|
-
*/
|
|
10
|
-
export class SqlQueryContext implements QueryContext {
|
|
11
|
-
private readonly sqlChunks: string[] = [];
|
|
12
|
-
private readonly params: unknown[] = [];
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param dialect The SQL dialect used to determine how values should be formatted as placeholders.
|
|
16
|
-
*/
|
|
17
|
-
constructor(readonly dialect: QueryDialect) {}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Appends raw SQL string fragments to the query.
|
|
21
|
-
*
|
|
22
|
-
* @param sql The SQL fragment to append.
|
|
23
|
-
* @returns The current context instance for method chaining.
|
|
24
|
-
*/
|
|
25
|
-
append(sql: string): this {
|
|
26
|
-
if (sql) {
|
|
27
|
-
this.sqlChunks.push(sql);
|
|
28
|
-
}
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Adds a value to the query parameters and appends its corresponding placeholder to the SQL.
|
|
34
|
-
* The placeholder format is determined by the dialect (e.g., '?' or '$1').
|
|
35
|
-
*
|
|
36
|
-
* @param value The value to be parameterized.
|
|
37
|
-
* @returns The current context instance for method chaining.
|
|
38
|
-
*/
|
|
39
|
-
addValue(value: unknown): this {
|
|
40
|
-
this.sqlChunks.push(this.dialect.addValue(this.params, value));
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Pushes a value to the parameters list without appending a placeholder to the SQL.
|
|
46
|
-
* This is useful when the placeholder is already present in the SQL string or handled elsewhere.
|
|
47
|
-
*
|
|
48
|
-
* @param value The value to be added to the parameters.
|
|
49
|
-
* @returns The current context instance for method chaining.
|
|
50
|
-
*/
|
|
51
|
-
pushValue(value: unknown): this {
|
|
52
|
-
this.params.push(value);
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Returns the complete SQL query string by joining all accumulated chunks.
|
|
58
|
-
*/
|
|
59
|
-
get sql() {
|
|
60
|
-
return this.sqlChunks.join('');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Returns the array of collected parameter values in the order they were added.
|
|
65
|
-
*/
|
|
66
|
-
get values() {
|
|
67
|
-
return this.params;
|
|
68
|
-
}
|
|
69
|
-
}
|