@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.
Files changed (37) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +15 -0
  3. package/README.md +57 -2
  4. package/dist/database/duraxis-orm.d.ts +16 -0
  5. package/dist/database/orm-options.d.ts +12 -0
  6. package/dist/decorators/column.decorator.d.ts +2 -0
  7. package/dist/decorators/entity.decorator.d.ts +1 -0
  8. package/dist/decorators/index.decorator.d.ts +13 -0
  9. package/dist/decorators/primary-key.decorator.d.ts +2 -0
  10. package/dist/decorators/relation.decorators.d.ts +19 -0
  11. package/dist/errors/index.d.ts +32 -0
  12. package/dist/index.cjs +1434 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.ts +27 -0
  15. package/dist/index.js +1388 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/mapping/entity-hydrator.d.ts +11 -0
  18. package/dist/mapping/entity-mapper.d.ts +15 -0
  19. package/dist/mapping/value-transformer.d.ts +6 -0
  20. package/dist/metadata/decorator-metadata.d.ts +50 -0
  21. package/dist/metadata/entity-metadata.d.ts +68 -0
  22. package/dist/metadata/metadata-registry.d.ts +11 -0
  23. package/dist/metadata/metadata-validator.d.ts +4 -0
  24. package/dist/query/find-options.d.ts +21 -0
  25. package/dist/query/query-builder.d.ts +50 -0
  26. package/dist/query/query-mapper.d.ts +14 -0
  27. package/dist/query/where-operator.d.ts +26 -0
  28. package/dist/relations/relation-loader.d.ts +17 -0
  29. package/dist/relations/relation-operations.d.ts +10 -0
  30. package/dist/repository/repository-errors.d.ts +1 -0
  31. package/dist/repository/repository-options.d.ts +8 -0
  32. package/dist/repository/repository.d.ts +35 -0
  33. package/dist/schema/schema-manager.d.ts +12 -0
  34. package/dist/schema/schema-mapper.d.ts +4 -0
  35. package/dist/transactions/orm-transaction.d.ts +15 -0
  36. package/dist/transactions/transaction-context.d.ts +5 -0
  37. package/package.json +59 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # @duraxis/orm changelog
2
+
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 8c357b5: fix: padronize the published versions
8
+ - 8c357b5: fix: padronize the published versions
9
+ - Updated dependencies [8c357b5]
10
+ - Updated dependencies [8c357b5]
11
+ - @duraxis/core@0.2.2
12
+
13
+ ## 0.2.1
14
+
15
+ ### Patch Changes
16
+
17
+ - e6facc7: fix: padronize the published versions
18
+ - Updated dependencies [e6facc7]
19
+ - @duraxis/core@0.2.1
20
+
21
+ ## 0.2.0
22
+
23
+ ### Minor Changes
24
+
25
+ - 6123078: Add transactional foreign-key integrity, referential actions, ORM relationship decorators, batched relation loading, and ManyToMany association operations.
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [6123078]
30
+ - @duraxis/core@0.2.0
31
+
32
+ This file is maintained by Changesets. Future releases will add versioned
33
+ entries automatically.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 João Paulo Dias
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,58 @@
1
- # Temporary Holding Version
1
+ # @duraxis/orm
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Camada de mapeamento de entidades sobre `@duraxis/core`. Fornece decorators de metadados,
4
+ validação/criação de schema, repositórios tipados, query builder e transações ORM.
5
+
6
+ ## Instalação
7
+
8
+ ```bash
9
+ pnpm add @duraxis/orm @duraxis/core @duraxis/storage-memory
10
+ npm install @duraxis/orm @duraxis/core @duraxis/storage-memory
11
+ yarn add @duraxis/orm @duraxis/core @duraxis/storage-memory
12
+ ```
13
+
14
+ Habilite `experimentalDecorators` e `emitDecoratorMetadata` no TypeScript.
15
+
16
+ ## Uso
17
+
18
+ ```ts
19
+ import { DuraxisDatabase } from "@duraxis/core";
20
+ import { Column, DuraxisORM, Entity, PrimaryKey } from "@duraxis/orm";
21
+ import { MemoryStorageDriver } from "@duraxis/storage-memory";
22
+
23
+ @Entity("users")
24
+ class User {
25
+ @PrimaryKey()
26
+ id!: string;
27
+
28
+ @Column({ type: "string", required: true })
29
+ email!: string;
30
+ }
31
+
32
+ const database = new DuraxisDatabase({ storage: new MemoryStorageDriver() });
33
+ const orm = new DuraxisORM({
34
+ database,
35
+ entities: [User],
36
+ schema: { mode: "create" },
37
+ closeDatabase: true,
38
+ });
39
+
40
+ await orm.initialize();
41
+ const users = orm.getRepository(User);
42
+ await users.insert({ id: "1", email: "user@example.com" });
43
+ const user = await users.findById("1");
44
+ await orm.close();
45
+ ```
46
+
47
+ ## API principal
48
+
49
+ - `@Entity`, `@Column`, `@PrimaryKey` e `@Index`;
50
+ - `DuraxisORM`, `Repository` e `QueryBuilder`;
51
+ - `find`, `findOne`, `findById`, paginação, contagem, inserção, update, upsert e delete;
52
+ - `orm.transaction`, `OrmTransactionManager` e contexto transacional;
53
+ - registro/metadados, mapeadores, schema manager e erros específicos.
54
+
55
+ O ORM exige inicialização antes de obter repositórios. O modo `create` cria estruturas
56
+ ausentes, mas não é uma ferramenta geral de migrações destrutivas; `validate` verifica o schema
57
+ existente. Decorators registram metadados quando a classe é avaliada, por isso este pacote não é
58
+ marcado como livre de efeitos colaterais. Requer Node.js 22.12+.
@@ -0,0 +1,16 @@
1
+ import type { EntityClass } from "../metadata/entity-metadata.js";
2
+ import { MetadataRegistry } from "../metadata/metadata-registry.js";
3
+ import { Repository } from "../repository/repository.js";
4
+ import type { TransactionContext } from "../transactions/transaction-context.js";
5
+ import type { DuraxisOrmOptions } from "./orm-options.js";
6
+ export declare class DuraxisORM {
7
+ #private;
8
+ private readonly options;
9
+ constructor(options: DuraxisOrmOptions);
10
+ initialize(): Promise<void>;
11
+ getRepository<TEntity extends object>(entity: EntityClass<TEntity>): Repository<TEntity>;
12
+ transaction<TResult>(callback: (manager: TransactionContext) => Promise<TResult> | TResult): Promise<TResult>;
13
+ close(): Promise<void>;
14
+ get metadata(): MetadataRegistry;
15
+ private assertReady;
16
+ }
@@ -0,0 +1,12 @@
1
+ import type { DuraxisDatabase } from "@duraxis/core";
2
+ import type { EntityClass } from "../metadata/entity-metadata.js";
3
+ import type { SchemaMode } from "../schema/schema-manager.js";
4
+ export interface DuraxisOrmOptions {
5
+ readonly database: DuraxisDatabase;
6
+ readonly entities: readonly EntityClass[];
7
+ readonly schema?: {
8
+ readonly mode: SchemaMode;
9
+ };
10
+ readonly closeDatabase?: boolean;
11
+ readonly closeStorage?: boolean;
12
+ }
@@ -0,0 +1,2 @@
1
+ import type { ColumnOptions } from "../metadata/entity-metadata.js";
2
+ export declare function Column(options: ColumnOptions): PropertyDecorator;
@@ -0,0 +1 @@
1
+ export declare function Entity(name?: string): ClassDecorator;
@@ -0,0 +1,13 @@
1
+ export interface PropertyIndexOptions {
2
+ readonly name?: string;
3
+ readonly unique?: boolean;
4
+ }
5
+ export interface CompositeIndexField {
6
+ readonly property: string;
7
+ readonly order?: "ASC" | "DESC";
8
+ }
9
+ export interface CompositeIndexOptions {
10
+ readonly unique?: boolean;
11
+ }
12
+ export declare function Index(options?: PropertyIndexOptions): PropertyDecorator;
13
+ export declare function Index(name: string, fields: readonly CompositeIndexField[], options?: CompositeIndexOptions): ClassDecorator;
@@ -0,0 +1,2 @@
1
+ /** Declares the logical record identifier. It is never stored inside the document. */
2
+ export declare function PrimaryKey(): PropertyDecorator;
@@ -0,0 +1,19 @@
1
+ import type { ReferentialAction } from "@duraxis/core";
2
+ import type { EntityClass } from "../metadata/entity-metadata.js";
3
+ export interface OwningRelationOptions {
4
+ readonly foreignKey: string;
5
+ readonly onDelete?: ReferentialAction;
6
+ }
7
+ export interface JoinTableOptions {
8
+ readonly name: string;
9
+ readonly joinColumn?: string;
10
+ readonly inverseJoinColumn?: string;
11
+ }
12
+ type TargetFactory<TTarget extends object> = () => EntityClass<TTarget>;
13
+ type Selector<TTarget extends object> = (entity: TTarget) => unknown;
14
+ export declare function ManyToOne<TTarget extends object>(target: TargetFactory<TTarget>, options: OwningRelationOptions): PropertyDecorator;
15
+ export declare function OneToMany<TTarget extends object>(target: TargetFactory<TTarget>, inverse: Selector<TTarget>): PropertyDecorator;
16
+ export declare function OneToOne<TTarget extends object>(target: TargetFactory<TTarget>, inverseOrOptions: Selector<TTarget> | OwningRelationOptions): PropertyDecorator;
17
+ export declare function ManyToMany<TTarget extends object>(target: TargetFactory<TTarget>, inverse: Selector<TTarget>): PropertyDecorator;
18
+ export declare function JoinTable(options: JoinTableOptions): PropertyDecorator;
19
+ export {};
@@ -0,0 +1,32 @@
1
+ export declare class DuraxisOrmError extends Error {
2
+ constructor(message: string, options?: ErrorOptions);
3
+ }
4
+ export declare class EntityNotRegisteredError extends DuraxisOrmError {
5
+ constructor(entity: Function);
6
+ }
7
+ export declare class InvalidMetadataError extends DuraxisOrmError {
8
+ }
9
+ export declare class MissingPrimaryKeyError extends InvalidMetadataError {
10
+ }
11
+ export declare class DuplicateRecordError extends DuraxisOrmError {
12
+ }
13
+ export declare class RecordNotFoundError extends DuraxisOrmError {
14
+ }
15
+ export declare class InvalidColumnError extends DuraxisOrmError {
16
+ }
17
+ export declare class SchemaViolationError extends DuraxisOrmError {
18
+ }
19
+ export declare class InvalidQueryError extends DuraxisOrmError {
20
+ }
21
+ export declare class UniqueIndexViolationOrmError extends DuraxisOrmError {
22
+ constructor(message: string, cause: unknown);
23
+ }
24
+ export declare class OrmNotInitializedError extends DuraxisOrmError {
25
+ constructor();
26
+ }
27
+ export declare class OrmClosedError extends DuraxisOrmError {
28
+ constructor();
29
+ }
30
+ export declare class TransactionManagerClosedError extends DuraxisOrmError {
31
+ constructor();
32
+ }