@duraxis/orm 0.0.0-stage → 0.2.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 +33 -0
- package/LICENSE +15 -0
- package/README.md +57 -2
- package/dist/database/duraxis-orm.d.ts +16 -0
- package/dist/database/orm-options.d.ts +12 -0
- package/dist/decorators/column.decorator.d.ts +2 -0
- package/dist/decorators/entity.decorator.d.ts +1 -0
- package/dist/decorators/index.decorator.d.ts +13 -0
- package/dist/decorators/primary-key.decorator.d.ts +2 -0
- package/dist/decorators/relation.decorators.d.ts +19 -0
- package/dist/errors/index.d.ts +32 -0
- package/dist/index.cjs +1434 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +1388 -0
- package/dist/index.js.map +1 -0
- package/dist/mapping/entity-hydrator.d.ts +11 -0
- package/dist/mapping/entity-mapper.d.ts +15 -0
- package/dist/mapping/value-transformer.d.ts +6 -0
- package/dist/metadata/decorator-metadata.d.ts +50 -0
- package/dist/metadata/entity-metadata.d.ts +68 -0
- package/dist/metadata/metadata-registry.d.ts +11 -0
- package/dist/metadata/metadata-validator.d.ts +4 -0
- package/dist/query/find-options.d.ts +21 -0
- package/dist/query/query-builder.d.ts +50 -0
- package/dist/query/query-mapper.d.ts +14 -0
- package/dist/query/where-operator.d.ts +26 -0
- package/dist/relations/relation-loader.d.ts +17 -0
- package/dist/relations/relation-operations.d.ts +10 -0
- package/dist/repository/repository-errors.d.ts +1 -0
- package/dist/repository/repository-options.d.ts +8 -0
- package/dist/repository/repository.d.ts +35 -0
- package/dist/schema/schema-manager.d.ts +12 -0
- package/dist/schema/schema-mapper.d.ts +4 -0
- package/dist/transactions/orm-transaction.d.ts +15 -0
- package/dist/transactions/transaction-context.d.ts +5 -0
- package/package.json +59 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EntityMetadata } from "../metadata/entity-metadata.js";
|
|
2
|
+
import type { FindOptions, FindPage, Relations } from "../query/find-options.js";
|
|
3
|
+
import { QueryBuilder } from "../query/query-builder.js";
|
|
4
|
+
import type { RepositoryRuntime } from "./repository-options.js";
|
|
5
|
+
import { RelationOperations } from "../relations/relation-operations.js";
|
|
6
|
+
export declare class Repository<TEntity extends object> {
|
|
7
|
+
#private;
|
|
8
|
+
readonly metadata: EntityMetadata<TEntity>;
|
|
9
|
+
private readonly runtime;
|
|
10
|
+
constructor(metadata: EntityMetadata<TEntity>, runtime: RepositoryRuntime);
|
|
11
|
+
create(data: Partial<TEntity>): TEntity;
|
|
12
|
+
insert(entity: TEntity): Promise<TEntity>;
|
|
13
|
+
save(entity: TEntity): Promise<TEntity>;
|
|
14
|
+
update(id: string, changes: Partial<TEntity>): Promise<TEntity>;
|
|
15
|
+
upsert(entity: TEntity): Promise<TEntity>;
|
|
16
|
+
delete(id: string): Promise<boolean>;
|
|
17
|
+
findById(id: string, options?: {
|
|
18
|
+
readonly relations?: Relations<TEntity>;
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
}): Promise<TEntity | null>;
|
|
21
|
+
findOne(options?: FindOptions<TEntity>): Promise<TEntity | null>;
|
|
22
|
+
find(options?: FindOptions<TEntity>): Promise<readonly TEntity[]>;
|
|
23
|
+
findPage(options: FindOptions<TEntity>): Promise<FindPage<TEntity>>;
|
|
24
|
+
exists(options?: FindOptions<TEntity>): Promise<boolean>;
|
|
25
|
+
count(options?: Pick<FindOptions<TEntity>, "where" | "signal">): Promise<number>;
|
|
26
|
+
createQueryBuilder(): QueryBuilder<TEntity>;
|
|
27
|
+
relations<K extends Extract<keyof TEntity, string>>(property: K): RelationOperations<TEntity>;
|
|
28
|
+
private hydrate;
|
|
29
|
+
private loadRelations;
|
|
30
|
+
private mapFind;
|
|
31
|
+
private queryRows;
|
|
32
|
+
private queryPage;
|
|
33
|
+
private sourceQuery;
|
|
34
|
+
private write;
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DuraxisDatabase } from "@duraxis/core";
|
|
2
|
+
import type { MetadataRegistry } from "../metadata/metadata-registry.js";
|
|
3
|
+
export type SchemaMode = "validate" | "create";
|
|
4
|
+
export declare class SchemaManager {
|
|
5
|
+
private readonly database;
|
|
6
|
+
private readonly registry;
|
|
7
|
+
private readonly mode;
|
|
8
|
+
constructor(database: DuraxisDatabase, registry: MetadataRegistry, mode: SchemaMode);
|
|
9
|
+
initialize(): Promise<void>;
|
|
10
|
+
private validateFields;
|
|
11
|
+
private mutate;
|
|
12
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CollectionDefinition } from "@duraxis/core";
|
|
2
|
+
import type { EntityMetadata } from "../metadata/entity-metadata.js";
|
|
3
|
+
export declare function mapEntitySchema(metadata: EntityMetadata): CollectionDefinition;
|
|
4
|
+
export declare function mapJunctionSchemas(metadata: readonly EntityMetadata[]): readonly CollectionDefinition[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DuraxisDatabase, Transaction } from "@duraxis/core";
|
|
2
|
+
import type { EntityClass } from "../metadata/entity-metadata.js";
|
|
3
|
+
import type { MetadataRegistry } from "../metadata/metadata-registry.js";
|
|
4
|
+
import { Repository } from "../repository/repository.js";
|
|
5
|
+
import type { TransactionContext } from "./transaction-context.js";
|
|
6
|
+
export declare class OrmTransactionManager implements TransactionContext {
|
|
7
|
+
#private;
|
|
8
|
+
private readonly database;
|
|
9
|
+
private readonly transaction;
|
|
10
|
+
private readonly registry;
|
|
11
|
+
constructor(database: DuraxisDatabase, transaction: Transaction, registry: MetadataRegistry);
|
|
12
|
+
getRepository<TEntity extends object>(entity: EntityClass<TEntity>): Repository<TEntity>;
|
|
13
|
+
close(): void;
|
|
14
|
+
private assertActive;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duraxis/orm",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Decorator-based entity mapping and repositories for the Duraxis database.",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "João Paulo Dias <joaopdias.dev@gmail.com>",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"duraxis",
|
|
9
|
+
"database",
|
|
10
|
+
"orm",
|
|
11
|
+
"decorators",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/Joaopdiasventura/Duraxis.git",
|
|
17
|
+
"directory": "packages/orm"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/Joaopdiasventura/Duraxis/tree/main/packages/orm#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Joaopdiasventura/Duraxis/issues"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22.12.0"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./dist/index.cjs",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"require": "./dist/index.cjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE",
|
|
45
|
+
"CHANGELOG.md"
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@duraxis/core": "0.2.2"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@duraxis/storage": "0.1.2",
|
|
52
|
+
"@duraxis/storage-memory": "0.1.3",
|
|
53
|
+
"@duraxis/storage-disk": "0.1.3"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
57
|
+
"dev": "vite build --watch",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"test": "vitest run",
|
|
60
|
+
"test:watch": "vitest"
|
|
61
|
+
}
|
|
6
62
|
}
|