@duraxis/orm 0.1.0 → 0.3.0
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 +40 -0
- package/README.md +15 -1
- package/dist/decorators/relation.decorators.d.ts +19 -0
- package/dist/index.cjs +482 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +475 -26
- package/dist/index.js.map +1 -1
- package/dist/metadata/decorator-metadata.d.ts +19 -0
- package/dist/metadata/entity-metadata.d.ts +23 -0
- package/dist/metadata/metadata-registry.d.ts +1 -1
- package/dist/metadata/metadata-validator.d.ts +2 -0
- package/dist/query/find-options.d.ts +6 -0
- package/dist/relations/relation-loader.d.ts +17 -0
- package/dist/relations/relation-operations.d.ts +10 -0
- package/dist/repository/repository-options.d.ts +2 -0
- package/dist/repository/repository.d.ts +9 -2
- package/dist/schema/schema-exporter.d.ts +5 -0
- package/dist/schema/schema-manager.d.ts +1 -1
- package/dist/schema/schema-mapper.d.ts +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Transaction } from "@duraxis/core";
|
|
2
|
+
import type { EntityMetadata, RelationMetadata } from "../metadata/entity-metadata.js";
|
|
3
|
+
export declare class RelationOperations<TEntity extends object = Record<string, unknown>> {
|
|
4
|
+
private readonly metadata;
|
|
5
|
+
private readonly relation;
|
|
6
|
+
private readonly write;
|
|
7
|
+
constructor(metadata: EntityMetadata<TEntity>, relation: RelationMetadata<TEntity>, write: (action: (transaction: Transaction) => Promise<void>) => Promise<void>);
|
|
8
|
+
add(sourceId: string, targetId: string): Promise<void>;
|
|
9
|
+
remove(sourceId: string, targetId: string): Promise<boolean>;
|
|
10
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { DuraxisDatabase, Transaction } from "@duraxis/core";
|
|
2
|
+
import type { MetadataRegistry } from "../metadata/metadata-registry.js";
|
|
2
3
|
export interface RepositoryRuntime {
|
|
3
4
|
readonly database: DuraxisDatabase;
|
|
4
5
|
readonly transaction?: Transaction;
|
|
5
6
|
readonly assertUsable: () => void;
|
|
7
|
+
readonly registry: MetadataRegistry;
|
|
6
8
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { EntityMetadata } from "../metadata/entity-metadata.js";
|
|
2
|
-
import type { FindOptions, FindPage } from "../query/find-options.js";
|
|
2
|
+
import type { FindOptions, FindPage, Relations } from "../query/find-options.js";
|
|
3
3
|
import { QueryBuilder } from "../query/query-builder.js";
|
|
4
4
|
import type { RepositoryRuntime } from "./repository-options.js";
|
|
5
|
+
import { RelationOperations } from "../relations/relation-operations.js";
|
|
5
6
|
export declare class Repository<TEntity extends object> {
|
|
6
7
|
#private;
|
|
7
8
|
readonly metadata: EntityMetadata<TEntity>;
|
|
@@ -13,14 +14,20 @@ export declare class Repository<TEntity extends object> {
|
|
|
13
14
|
update(id: string, changes: Partial<TEntity>): Promise<TEntity>;
|
|
14
15
|
upsert(entity: TEntity): Promise<TEntity>;
|
|
15
16
|
delete(id: string): Promise<boolean>;
|
|
16
|
-
findById(id: string
|
|
17
|
+
findById(id: string, options?: {
|
|
18
|
+
readonly relations?: Relations<TEntity>;
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
}): Promise<TEntity | null>;
|
|
17
21
|
findOne(options?: FindOptions<TEntity>): Promise<TEntity | null>;
|
|
18
22
|
find(options?: FindOptions<TEntity>): Promise<readonly TEntity[]>;
|
|
19
23
|
findPage(options: FindOptions<TEntity>): Promise<FindPage<TEntity>>;
|
|
20
24
|
exists(options?: FindOptions<TEntity>): Promise<boolean>;
|
|
21
25
|
count(options?: Pick<FindOptions<TEntity>, "where" | "signal">): Promise<number>;
|
|
22
26
|
createQueryBuilder(): QueryBuilder<TEntity>;
|
|
27
|
+
relations<K extends Extract<keyof TEntity, string>>(property: K): RelationOperations<TEntity>;
|
|
23
28
|
private hydrate;
|
|
29
|
+
private loadRelations;
|
|
30
|
+
private mapFind;
|
|
24
31
|
private queryRows;
|
|
25
32
|
private queryPage;
|
|
26
33
|
private sourceQuery;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type CollectionDefinition } from "@duraxis/core";
|
|
2
|
+
import { MetadataRegistry } from "../metadata/metadata-registry.js";
|
|
3
|
+
import type { EntityClass } from "../metadata/entity-metadata.js";
|
|
4
|
+
export declare function exportRegistrySchema(registry: MetadataRegistry): readonly CollectionDefinition[];
|
|
5
|
+
export declare function exportSchema(entities: readonly EntityClass[]): readonly CollectionDefinition[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DuraxisDatabase } from "@duraxis/core";
|
|
2
2
|
import type { MetadataRegistry } from "../metadata/metadata-registry.js";
|
|
3
|
-
export type SchemaMode = "validate" | "create";
|
|
3
|
+
export type SchemaMode = "validate" | "validate-managed" | "create";
|
|
4
4
|
export declare class SchemaManager {
|
|
5
5
|
private readonly database;
|
|
6
6
|
private readonly registry;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { CollectionDefinition } from "@duraxis/core";
|
|
2
2
|
import type { EntityMetadata } from "../metadata/entity-metadata.js";
|
|
3
3
|
export declare function mapEntitySchema(metadata: EntityMetadata): CollectionDefinition;
|
|
4
|
+
export declare function mapJunctionSchemas(metadata: readonly EntityMetadata[]): readonly CollectionDefinition[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duraxis/orm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Decorator-based entity mapping and repositories for the Duraxis database.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "João Paulo Dias <joaopdias.dev@gmail.com>",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://github.com/Joaopdiasventura/Duraxis/issues"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": ">=24.15.0"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"CHANGELOG.md"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@duraxis/core": "0.
|
|
48
|
+
"@duraxis/core": "0.3.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@duraxis/storage": "0.1.
|
|
52
|
-
"@duraxis/storage-memory": "0.1.
|
|
53
|
-
"@duraxis/storage-disk": "0.1.
|
|
51
|
+
"@duraxis/storage": "0.1.2",
|
|
52
|
+
"@duraxis/storage-memory": "0.1.3",
|
|
53
|
+
"@duraxis/storage-disk": "0.1.3"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "vite build && tsc -p tsconfig.build.json",
|