@carno.js/orm 0.2.3
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/LICENSE +674 -0
- package/dist/SqlBuilder.d.ts +103 -0
- package/dist/SqlBuilder.js +618 -0
- package/dist/cache/cache-key-generator.d.ts +13 -0
- package/dist/cache/cache-key-generator.js +66 -0
- package/dist/cache/query-cache-manager.d.ts +14 -0
- package/dist/cache/query-cache-manager.js +44 -0
- package/dist/common/email.vo.d.ts +4 -0
- package/dist/common/email.vo.js +11 -0
- package/dist/common/uuid.d.ts +4 -0
- package/dist/common/uuid.js +10 -0
- package/dist/common/value-object.d.ts +95 -0
- package/dist/common/value-object.js +99 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.js +9 -0
- package/dist/decorators/computed.decorator.d.ts +1 -0
- package/dist/decorators/computed.decorator.js +12 -0
- package/dist/decorators/entity.decorator.d.ts +3 -0
- package/dist/decorators/entity.decorator.js +12 -0
- package/dist/decorators/enum.decorator.d.ts +2 -0
- package/dist/decorators/enum.decorator.js +16 -0
- package/dist/decorators/event-hook.decorator.d.ts +4 -0
- package/dist/decorators/event-hook.decorator.js +31 -0
- package/dist/decorators/index.decorator.d.ts +17 -0
- package/dist/decorators/index.decorator.js +36 -0
- package/dist/decorators/one-many.decorator.d.ts +6 -0
- package/dist/decorators/one-many.decorator.js +42 -0
- package/dist/decorators/primary-key.decorator.d.ts +2 -0
- package/dist/decorators/primary-key.decorator.js +8 -0
- package/dist/decorators/property.decorator.d.ts +24 -0
- package/dist/decorators/property.decorator.js +44 -0
- package/dist/decorators/unique.decorator.d.ts +9 -0
- package/dist/decorators/unique.decorator.js +44 -0
- package/dist/domain/base-entity.d.ts +57 -0
- package/dist/domain/base-entity.js +198 -0
- package/dist/domain/collection.d.ts +6 -0
- package/dist/domain/collection.js +15 -0
- package/dist/domain/entities.d.ts +49 -0
- package/dist/domain/entities.js +259 -0
- package/dist/domain/reference.d.ts +86 -0
- package/dist/domain/reference.js +86 -0
- package/dist/driver/bun-driver.base.d.ts +72 -0
- package/dist/driver/bun-driver.base.js +270 -0
- package/dist/driver/bun-mysql.driver.d.ts +53 -0
- package/dist/driver/bun-mysql.driver.js +256 -0
- package/dist/driver/bun-pg.driver.d.ts +52 -0
- package/dist/driver/bun-pg.driver.js +263 -0
- package/dist/driver/driver.interface.d.ts +333 -0
- package/dist/driver/driver.interface.js +2 -0
- package/dist/entry.d.ts +2 -0
- package/dist/entry.js +13 -0
- package/dist/identity-map/entity-key-generator.d.ts +10 -0
- package/dist/identity-map/entity-key-generator.js +45 -0
- package/dist/identity-map/entity-registry.d.ts +11 -0
- package/dist/identity-map/entity-registry.js +41 -0
- package/dist/identity-map/identity-map-context.d.ts +9 -0
- package/dist/identity-map/identity-map-context.js +22 -0
- package/dist/identity-map/identity-map-integration.d.ts +5 -0
- package/dist/identity-map/identity-map-integration.js +37 -0
- package/dist/identity-map/identity-map.d.ts +11 -0
- package/dist/identity-map/identity-map.js +35 -0
- package/dist/identity-map/index.d.ts +5 -0
- package/dist/identity-map/index.js +14 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +48 -0
- package/dist/middleware/identity-map.middleware.d.ts +4 -0
- package/dist/middleware/identity-map.middleware.js +22 -0
- package/dist/orm-session-context.d.ts +16 -0
- package/dist/orm-session-context.js +22 -0
- package/dist/orm.d.ts +20 -0
- package/dist/orm.js +69 -0
- package/dist/orm.service.d.ts +13 -0
- package/dist/orm.service.js +361 -0
- package/dist/query/index-condition-builder.d.ts +41 -0
- package/dist/query/index-condition-builder.js +235 -0
- package/dist/query/model-transformer.d.ts +27 -0
- package/dist/query/model-transformer.js +201 -0
- package/dist/query/sql-column-manager.d.ts +28 -0
- package/dist/query/sql-column-manager.js +157 -0
- package/dist/query/sql-condition-builder.d.ts +51 -0
- package/dist/query/sql-condition-builder.js +264 -0
- package/dist/query/sql-join-manager.d.ts +39 -0
- package/dist/query/sql-join-manager.js +242 -0
- package/dist/query/sql-subquery-builder.d.ts +20 -0
- package/dist/query/sql-subquery-builder.js +119 -0
- package/dist/repository/Repository.d.ts +121 -0
- package/dist/repository/Repository.js +174 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +17 -0
- package/dist/testing/with-database.d.ts +20 -0
- package/dist/testing/with-database.js +311 -0
- package/dist/transaction/transaction-context.d.ts +10 -0
- package/dist/transaction/transaction-context.js +19 -0
- package/dist/utils/value-processor.d.ts +14 -0
- package/dist/utils/value-processor.js +94 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +24 -0
- package/package.json +59 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AutoPath, FilterQuery, QueryOrderMap, ValueOrInstance } from './driver/driver.interface';
|
|
2
|
+
export declare class SqlBuilder<T> {
|
|
3
|
+
private readonly driver;
|
|
4
|
+
private entityStorage;
|
|
5
|
+
private statements;
|
|
6
|
+
private entity;
|
|
7
|
+
private model;
|
|
8
|
+
private aliases;
|
|
9
|
+
private logger;
|
|
10
|
+
private updatedColumns;
|
|
11
|
+
private originalColumns;
|
|
12
|
+
private conditionBuilder;
|
|
13
|
+
private modelTransformer;
|
|
14
|
+
private columnManager;
|
|
15
|
+
private joinManager;
|
|
16
|
+
private cacheManager?;
|
|
17
|
+
constructor(model: new () => T);
|
|
18
|
+
private initializeCacheManager;
|
|
19
|
+
select(columns?: AutoPath<T, never, '*'>[]): SqlBuilder<T>;
|
|
20
|
+
setStrategy(strategy?: 'joined' | 'select'): SqlBuilder<T>;
|
|
21
|
+
setInstance(instance: T): SqlBuilder<T>;
|
|
22
|
+
insert(values: Partial<{
|
|
23
|
+
[K in keyof T]: ValueOrInstance<T[K]>;
|
|
24
|
+
}>): SqlBuilder<T>;
|
|
25
|
+
update(values: Partial<{
|
|
26
|
+
[K in keyof T]: ValueOrInstance<T[K]>;
|
|
27
|
+
}>): SqlBuilder<T>;
|
|
28
|
+
delete(): SqlBuilder<T>;
|
|
29
|
+
where(where: FilterQuery<T>): SqlBuilder<T>;
|
|
30
|
+
orderBy(orderBy: (QueryOrderMap<T> & {
|
|
31
|
+
0?: never;
|
|
32
|
+
}) | QueryOrderMap<T>[]): SqlBuilder<T>;
|
|
33
|
+
limit(limit: number | undefined): SqlBuilder<T>;
|
|
34
|
+
offset(offset: number | undefined): SqlBuilder<T>;
|
|
35
|
+
cache(cache: boolean | number | Date | undefined): SqlBuilder<T>;
|
|
36
|
+
load(load: string[]): SqlBuilder<T>;
|
|
37
|
+
count(): SqlBuilder<T>;
|
|
38
|
+
private getPrimaryKeyColumnName;
|
|
39
|
+
private shouldUseCache;
|
|
40
|
+
private getCacheTtl;
|
|
41
|
+
private getCachedResult;
|
|
42
|
+
private setCachedResult;
|
|
43
|
+
execute(): Promise<{
|
|
44
|
+
query: any;
|
|
45
|
+
startTime: number;
|
|
46
|
+
sql: string;
|
|
47
|
+
}>;
|
|
48
|
+
private isWriteOperation;
|
|
49
|
+
private invalidateCache;
|
|
50
|
+
private prepareColumns;
|
|
51
|
+
private beforeHooks;
|
|
52
|
+
private afterHooks;
|
|
53
|
+
executeAndReturnFirst(): Promise<T | undefined>;
|
|
54
|
+
executeAndReturnFirstOrFail(): Promise<T>;
|
|
55
|
+
executeAndReturnAll(): Promise<T[]>;
|
|
56
|
+
private hasOneToManyJoinedJoin;
|
|
57
|
+
private getOriginEntityForJoin;
|
|
58
|
+
private findNestedModel;
|
|
59
|
+
private processOneToManyJoinedResult;
|
|
60
|
+
private processAllOneToManyJoinedResults;
|
|
61
|
+
private attachOneToManyRelations;
|
|
62
|
+
private removeDuplicatesByPrimaryKey;
|
|
63
|
+
private getPrimaryKeyName;
|
|
64
|
+
private getPrimaryKeyNameForEntity;
|
|
65
|
+
executeCount(): Promise<number>;
|
|
66
|
+
private logExecution;
|
|
67
|
+
inTransaction<T>(callback: (builder: SqlBuilder<T>) => Promise<T>): Promise<T>;
|
|
68
|
+
private objectToStringMap;
|
|
69
|
+
private mapObjectKey;
|
|
70
|
+
private isNestedObject;
|
|
71
|
+
private buildColumnPath;
|
|
72
|
+
private splitPath;
|
|
73
|
+
private resolvePathEntity;
|
|
74
|
+
private nextEntity;
|
|
75
|
+
private resolveColumn;
|
|
76
|
+
private joinSegments;
|
|
77
|
+
private getTableName;
|
|
78
|
+
private t;
|
|
79
|
+
private getEntity;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves an alias for a given table name.
|
|
82
|
+
*
|
|
83
|
+
* @param {string} tableName - The name of the table.
|
|
84
|
+
* @private
|
|
85
|
+
* @returns {string} - The alias for the table name.
|
|
86
|
+
*/
|
|
87
|
+
private getAlias;
|
|
88
|
+
private generateUniqueAlias;
|
|
89
|
+
private withDefaultValues;
|
|
90
|
+
private applyDefaultProperties;
|
|
91
|
+
private setDefaultValue;
|
|
92
|
+
private applyOnInsertProperties;
|
|
93
|
+
private applyOnInsert;
|
|
94
|
+
private withUpdatedValues;
|
|
95
|
+
private applyOnUpdate;
|
|
96
|
+
callHook(type: string, model?: any): void;
|
|
97
|
+
private executeHook;
|
|
98
|
+
private reflectToValues;
|
|
99
|
+
private shouldSkipKey;
|
|
100
|
+
private reflectKey;
|
|
101
|
+
private reflectProperty;
|
|
102
|
+
private reflectRelation;
|
|
103
|
+
}
|