@cheetah.js/orm 0.1.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.
Files changed (93) hide show
  1. package/README.md +228 -0
  2. package/build.ts +14 -0
  3. package/cheetah.config.ts +14 -0
  4. package/dist/SqlBuilder.d.ts +57 -0
  5. package/dist/SqlBuilder.js +436 -0
  6. package/dist/SqlBuilder.js.map +1 -0
  7. package/dist/bun/index.d.ts +13 -0
  8. package/dist/bun/index.js +224319 -0
  9. package/dist/bun/index.js.map +306 -0
  10. package/dist/cheetah.d.ts +1 -0
  11. package/dist/cheetah.js +24 -0
  12. package/dist/cheetah.js.map +1 -0
  13. package/dist/constants.d.ts +4 -0
  14. package/dist/constants.js +5 -0
  15. package/dist/constants.js.map +1 -0
  16. package/dist/decorators/entity.decorator.d.ts +3 -0
  17. package/dist/decorators/entity.decorator.js +10 -0
  18. package/dist/decorators/entity.decorator.js.map +1 -0
  19. package/dist/decorators/index.decorator.d.ts +3 -0
  20. package/dist/decorators/index.decorator.js +17 -0
  21. package/dist/decorators/index.decorator.js.map +1 -0
  22. package/dist/decorators/one-many.decorator.d.ts +3 -0
  23. package/dist/decorators/one-many.decorator.js +17 -0
  24. package/dist/decorators/one-many.decorator.js.map +1 -0
  25. package/dist/decorators/primary-key.decorator.d.ts +2 -0
  26. package/dist/decorators/primary-key.decorator.js +6 -0
  27. package/dist/decorators/primary-key.decorator.js.map +1 -0
  28. package/dist/decorators/property.decorator.d.ts +15 -0
  29. package/dist/decorators/property.decorator.js +25 -0
  30. package/dist/decorators/property.decorator.js.map +1 -0
  31. package/dist/domain/base-entity.d.ts +42 -0
  32. package/dist/domain/base-entity.js +106 -0
  33. package/dist/domain/base-entity.js.map +1 -0
  34. package/dist/domain/collection.d.ts +6 -0
  35. package/dist/domain/collection.js +11 -0
  36. package/dist/domain/collection.js.map +1 -0
  37. package/dist/domain/entities.d.ts +40 -0
  38. package/dist/domain/entities.js +137 -0
  39. package/dist/domain/entities.js.map +1 -0
  40. package/dist/domain/reference.d.ts +4 -0
  41. package/dist/domain/reference.js +7 -0
  42. package/dist/domain/reference.js.map +1 -0
  43. package/dist/driver/driver.interface.d.ts +270 -0
  44. package/dist/driver/driver.interface.js +2 -0
  45. package/dist/driver/driver.interface.js.map +1 -0
  46. package/dist/driver/pg-driver.d.ts +43 -0
  47. package/dist/driver/pg-driver.js +255 -0
  48. package/dist/driver/pg-driver.js.map +1 -0
  49. package/dist/index.d.ts +13 -0
  50. package/dist/index.js +16 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/migration/diff-calculator.d.ts +17 -0
  53. package/dist/migration/diff-calculator.js +230 -0
  54. package/dist/migration/diff-calculator.js.map +1 -0
  55. package/dist/migration/migrator.d.ts +18 -0
  56. package/dist/migration/migrator.js +233 -0
  57. package/dist/migration/migrator.js.map +1 -0
  58. package/dist/orm.d.ts +14 -0
  59. package/dist/orm.js +23 -0
  60. package/dist/orm.js.map +1 -0
  61. package/dist/orm.service.d.ts +8 -0
  62. package/dist/orm.service.js +115 -0
  63. package/dist/orm.service.js.map +1 -0
  64. package/dist/utils.d.ts +1 -0
  65. package/dist/utils.js +16 -0
  66. package/dist/utils.js.map +1 -0
  67. package/package.json +50 -0
  68. package/src/SqlBuilder.ts +542 -0
  69. package/src/cheetah.ts +28 -0
  70. package/src/constants.ts +4 -0
  71. package/src/decorators/entity.decorator.ts +10 -0
  72. package/src/decorators/index.decorator.ts +18 -0
  73. package/src/decorators/one-many.decorator.ts +19 -0
  74. package/src/decorators/primary-key.decorator.ts +6 -0
  75. package/src/decorators/property.decorator.ts +41 -0
  76. package/src/domain/base-entity.ts +149 -0
  77. package/src/domain/collection.ts +10 -0
  78. package/src/domain/entities.ts +159 -0
  79. package/src/domain/reference.ts +5 -0
  80. package/src/driver/driver.interface.ts +331 -0
  81. package/src/driver/pg-driver.ts +308 -0
  82. package/src/index.ts +17 -0
  83. package/src/migration/diff-calculator.ts +258 -0
  84. package/src/migration/migrator.ts +278 -0
  85. package/src/orm.service.ts +115 -0
  86. package/src/orm.ts +30 -0
  87. package/src/utils.ts +18 -0
  88. package/test/domain/base-entity.spec.ts +463 -0
  89. package/test/migration/.sql +5 -0
  90. package/test/migration/cheetah.config.ts +13 -0
  91. package/test/migration/migator.spec.ts +251 -0
  92. package/test/migration/test.sql +5 -0
  93. package/test/node-database.ts +32 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { Migrator } from "./migration/migrator";
2
+ import { Command } from 'commander';
3
+ const program = new Command();
4
+ program
5
+ .name('cheetah-cli')
6
+ .description('CLI to Cheetah.js ORM ');
7
+ program.command('migration:generate')
8
+ .description('generate a new migration file with a diff')
9
+ .action(async (str, options) => {
10
+ const migrator = new Migrator();
11
+ await migrator.initConfigFile();
12
+ await migrator.createMigration();
13
+ process.exit(0);
14
+ });
15
+ program.command('migration:run')
16
+ .description('run all pending migrations')
17
+ .action(async (str, options) => {
18
+ const migrator = new Migrator();
19
+ await migrator.initConfigFile();
20
+ await migrator.migrate();
21
+ process.exit(0);
22
+ });
23
+ program.parse();
24
+ //# sourceMappingURL=cheetah.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cheetah.js","sourceRoot":"","sources":["../src/cheetah.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,wBAAwB,CAAC,CAAA;AAE1C,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC;KAChC,WAAW,CAAC,2CAA2C,CAAC;KACxD,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;IAC3B,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAA;IAC/B,MAAM,QAAQ,CAAC,cAAc,EAAE,CAAA;IAC/B,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAA;IAChC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC;KAC3B,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;IAC7B,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAA;IAC/B,MAAM,QAAQ,CAAC,cAAc,EAAE,CAAA;IAC/B,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAA;IACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const ENTITIES = "cheetah:entities";
2
+ export declare const PROPERTIES = "cheetah:properties";
3
+ export declare const PROPERTIES_METADATA = "cheetah:properties:metadata";
4
+ export declare const PROPERTIES_RELATIONS = "cheetah:properties:relations";
@@ -0,0 +1,5 @@
1
+ export const ENTITIES = 'cheetah:entities';
2
+ export const PROPERTIES = 'cheetah:properties';
3
+ export const PROPERTIES_METADATA = 'cheetah:properties:metadata';
4
+ export const PROPERTIES_RELATIONS = 'cheetah:properties:relations';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AAC3C,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,8BAA8B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function Entity(options?: {
2
+ tableName?: string;
3
+ }): ClassDecorator;
@@ -0,0 +1,10 @@
1
+ import { ENTITIES } from '../constants';
2
+ import { Metadata } from '@cheetah.js/core';
3
+ export function Entity(options) {
4
+ return (target) => {
5
+ const entities = Metadata.get(ENTITIES, Reflect) || [];
6
+ entities.push({ target, options });
7
+ Metadata.set(ENTITIES, entities, Reflect);
8
+ };
9
+ }
10
+ //# sourceMappingURL=entity.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.decorator.js","sourceRoot":"","sources":["../../src/decorators/entity.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,UAAU,MAAM,CAAC,OAA8B;IACnD,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;QACvD,QAAQ,CAAC,IAAI,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC,CAAC;QACjC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function Index<T>(options?: {
2
+ properties: (keyof T)[];
3
+ }): PropertyDecorator;
@@ -0,0 +1,17 @@
1
+ import { Metadata } from '@cheetah.js/core';
2
+ export function Index(options) {
3
+ return (target, propertyKey) => {
4
+ const indexes = Metadata.get('indexes', target.constructor) || [];
5
+ let index;
6
+ if (options && options.properties) {
7
+ const properties = options.properties;
8
+ index = { name: `${properties.join('_')}_index`, properties: options.properties };
9
+ }
10
+ else {
11
+ index = { name: `${propertyKey}_index`, properties: [propertyKey] };
12
+ }
13
+ indexes.push(index);
14
+ Metadata.set('indexes', indexes, target.constructor);
15
+ };
16
+ }
17
+ //# sourceMappingURL=index.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.decorator.js","sourceRoot":"","sources":["../../src/decorators/index.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,UAAU,KAAK,CAAI,OAAqC;IAC5D,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,EAAE;QACnD,MAAM,OAAO,GAA2C,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAC1G,IAAI,KAA2C,CAAC;QAEhD,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE;YACjC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAiB,CAAC;YAC7C,KAAK,GAAG,EAAC,IAAI,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,UAAiB,EAAC,CAAC;SACxF;aAAM;YACL,KAAK,GAAG,EAAC,IAAI,EAAE,GAAG,WAAqB,QAAQ,EAAE,UAAU,EAAE,CAAC,WAAqB,CAAC,EAAC,CAAE;SACxF;QAED,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { EntityName } from '../driver/driver.interface';
2
+ export declare function OneToMany<T>(entity: () => EntityName<T>, fkKey: (string & keyof T) | ((e: T) => any)): PropertyDecorator;
3
+ export declare function ManyToOne<T>(entity: () => EntityName<T>): PropertyDecorator;
@@ -0,0 +1,17 @@
1
+ import { PROPERTIES_RELATIONS } from '../constants';
2
+ import { Metadata } from '@cheetah.js/core';
3
+ export function OneToMany(entity, fkKey) {
4
+ return (target, propertyKey) => {
5
+ const existing = Metadata.get(PROPERTIES_RELATIONS, target.constructor) || [];
6
+ existing.push({ relation: 'one-to-many', propertyKey, isRelation: true, entity, fkKey, type: Metadata.getType(target, propertyKey) });
7
+ Metadata.set(PROPERTIES_RELATIONS, existing, target.constructor);
8
+ };
9
+ }
10
+ export function ManyToOne(entity) {
11
+ return (target, propertyKey) => {
12
+ const existing = Metadata.get(PROPERTIES_RELATIONS, target.constructor) || [];
13
+ existing.push({ relation: 'many-to-one', propertyKey, isRelation: true, entity, type: Metadata.getType(target, propertyKey) });
14
+ Metadata.set(PROPERTIES_RELATIONS, existing, target.constructor);
15
+ };
16
+ }
17
+ //# sourceMappingURL=one-many.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one-many.decorator.js","sourceRoot":"","sources":["../../src/decorators/one-many.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,UAAU,SAAS,CAAI,MAA2B,EAAE,KAA2C;IACnG,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,MAAM,QAAQ,GAAsB,QAAQ,CAAC,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACjG,QAAQ,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,EAAC,CAAC,CAAC;QACpI,QAAQ,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACnE,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,MAA2B;IACtD,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,MAAM,QAAQ,GAAsB,QAAQ,CAAC,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACjG,QAAQ,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,EAAC,CAAC,CAAC;QAC7H,QAAQ,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACnE,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { PropertyOptions } from './property.decorator';
2
+ export declare function PrimaryKey(options?: Omit<PropertyOptions, 'isPrimary'>): PropertyDecorator;
@@ -0,0 +1,6 @@
1
+ import { Property } from './property.decorator';
2
+ export function PrimaryKey(options) {
3
+ const isPrimary = true;
4
+ return Property({ ...options, isPrimary, unique: true });
5
+ }
6
+ //# sourceMappingURL=primary-key.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primary-key.decorator.js","sourceRoot":"","sources":["../../src/decorators/primary-key.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAEjE,MAAM,UAAU,UAAU,CAAC,OAA4C;IACrE,MAAM,SAAS,GAAG,IAAI,CAAC;IACvB,OAAO,QAAQ,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,15 @@
1
+ export type PropertyOptions = {
2
+ isPrimary?: boolean;
3
+ nullable?: boolean;
4
+ default?: any;
5
+ length?: number;
6
+ unique?: boolean;
7
+ autoIncrement?: boolean;
8
+ onUpdate?: () => any;
9
+ onInsert?: () => any;
10
+ };
11
+ export type Prop = {
12
+ propertyKey: any;
13
+ options: PropertyOptions | undefined;
14
+ };
15
+ export declare function Property(options?: PropertyOptions): PropertyDecorator;
@@ -0,0 +1,25 @@
1
+ import { PROPERTIES, PROPERTIES_METADATA } from '../constants';
2
+ import { getDefaultLength } from '../utils';
3
+ import { Metadata } from '@cheetah.js/core';
4
+ export function Property(options) {
5
+ return (target, propertyKey) => {
6
+ const properties = Metadata.get(PROPERTIES, target.constructor) || [];
7
+ const type = Metadata.getType(target, propertyKey);
8
+ const length = (options && options.length) || getDefaultLength(type.name);
9
+ options = { length, ...options };
10
+ properties.push({ propertyKey, options });
11
+ Metadata.set(PROPERTIES, properties, target.constructor);
12
+ if (options.isPrimary) {
13
+ const indexes = Metadata.get('indexes', target.constructor) || [];
14
+ indexes.push({ name: `[TABLE]_pkey`, properties: [propertyKey] });
15
+ Metadata.set('indexes', indexes, target.constructor);
16
+ }
17
+ properties.forEach((property) => {
18
+ const types = Metadata.get(PROPERTIES_METADATA, target.constructor) || {};
19
+ const type = Metadata.getType(target, property.propertyKey);
20
+ types[property.propertyKey] = { type, options: property.options };
21
+ Metadata.set(PROPERTIES_METADATA, types, target.constructor);
22
+ });
23
+ };
24
+ }
25
+ //# sourceMappingURL=property.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property.decorator.js","sourceRoot":"","sources":["../../src/decorators/property.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAe5C,MAAM,UAAU,QAAQ,CAAC,OAAyB;IAChD,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,MAAM,UAAU,GAAW,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAC9E,MAAM,IAAI,GAAG,QAAQ,CAAC,OA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@ -0,0 +1,42 @@
1
+ import { SqlBuilder } from '../SqlBuilder';
2
+ import { FilterQuery, FindOneOption, FindOptions, InstanceOf } from '../driver/driver.interface';
3
+ export declare abstract class BaseEntity {
4
+ private _oldValues;
5
+ private _changedValues;
6
+ private $_isPersisted;
7
+ constructor();
8
+ /**
9
+ * Gets current entity's Repository.
10
+ */
11
+ static createQueryBuilder<T>(this: {
12
+ new (): T;
13
+ } & typeof BaseEntity): SqlBuilder<T>;
14
+ /**
15
+ * Gets current entity's Repository.
16
+ */
17
+ private createQueryBuilder;
18
+ static find<T, Hint extends string = never>(this: {
19
+ new (): T;
20
+ } & typeof BaseEntity, where: FilterQuery<T>, options?: FindOptions<T, Hint>): Promise<T[]>;
21
+ static findOne<T, Hint extends string = never>(this: {
22
+ new (): T;
23
+ } & typeof BaseEntity, where: FilterQuery<T>, options?: FindOneOption<T, Hint>): Promise<T | undefined>;
24
+ /**
25
+ * Find a record in the database based on the provided query where and return it, or throw an error if not found.
26
+ *
27
+ * @param {FilterQuery<T>} where - The query where used to search for the record.
28
+ * @param options
29
+ * @return {Promise<T>} - A promise that resolves with the found record.
30
+ */
31
+ static findOneOrFail<T, Hint extends string = never>(this: {
32
+ new (): T;
33
+ } & typeof BaseEntity, where: FilterQuery<T>, options?: FindOneOption<T, Hint>): Promise<T>;
34
+ static findAll<T extends object, Hint extends string = never>(this: {
35
+ new (): T;
36
+ } & typeof BaseEntity, options: FindOptions<T, Hint>): Promise<T[]>;
37
+ static create<T extends BaseEntity>(this: {
38
+ new (): T;
39
+ } & typeof BaseEntity, where: Partial<InstanceOf<T>>): Promise<T>;
40
+ static getTableName(): string;
41
+ save(): Promise<void>;
42
+ }
@@ -0,0 +1,106 @@
1
+ import { SqlBuilder } from '../SqlBuilder';
2
+ export class BaseEntity {
3
+ constructor() {
4
+ this._oldValues = {};
5
+ this._changedValues = {};
6
+ this.$_isPersisted = false;
7
+ return new Proxy(this, {
8
+ set(target, p, newValue) {
9
+ if (p.startsWith('$')) {
10
+ target[p] = newValue;
11
+ return true;
12
+ }
13
+ // se oldvalue não existir, é porque é a primeira vez que o atributo está sendo setado
14
+ if (!target._oldValues[p]) {
15
+ target._oldValues[p] = newValue;
16
+ }
17
+ // se o valor for diferente do valor antigo, é porque o valor foi alterado
18
+ if (target._oldValues[p] !== newValue) {
19
+ target._changedValues[p] = newValue;
20
+ }
21
+ target[p] = newValue;
22
+ return true;
23
+ },
24
+ });
25
+ }
26
+ /**
27
+ * Gets current entity's Repository.
28
+ */
29
+ static createQueryBuilder() {
30
+ return new SqlBuilder(this);
31
+ }
32
+ /**
33
+ * Gets current entity's Repository.
34
+ */
35
+ createQueryBuilder() {
36
+ // @ts-ignore
37
+ return new SqlBuilder(this.constructor);
38
+ }
39
+ static async find(where, options) {
40
+ return this.createQueryBuilder()
41
+ .select(options?.fields)
42
+ .where(where)
43
+ .limit(options?.limit)
44
+ .offset(options?.offset)
45
+ .orderBy(options?.orderBy)
46
+ .executeAndReturnAll();
47
+ }
48
+ static async findOne(where, options) {
49
+ return this.createQueryBuilder()
50
+ .select(options?.fields)
51
+ .where(where)
52
+ .executeAndReturnFirst();
53
+ }
54
+ /**
55
+ * Find a record in the database based on the provided query where and return it, or throw an error if not found.
56
+ *
57
+ * @param {FilterQuery<T>} where - The query where used to search for the record.
58
+ * @param options
59
+ * @return {Promise<T>} - A promise that resolves with the found record.
60
+ */
61
+ static async findOneOrFail(where, options) {
62
+ return this.createQueryBuilder()
63
+ // @ts-ignore
64
+ .select(options?.fields)
65
+ .where(where)
66
+ .orderBy(options?.orderBy)
67
+ .executeAndReturnFirstOrFail();
68
+ }
69
+ static async findAll(options) {
70
+ const builder = this.createQueryBuilder()
71
+ .select(options.fields)
72
+ .offset(options?.offset)
73
+ .limit(options.limit)
74
+ .orderBy(options?.orderBy);
75
+ return builder.executeAndReturnAll();
76
+ }
77
+ static async create(where) {
78
+ return this.createQueryBuilder()
79
+ .insert(where)
80
+ .executeAndReturnFirstOrFail();
81
+ }
82
+ static getTableName() {
83
+ if ('tableName' in this) {
84
+ return this.tableName;
85
+ }
86
+ return this.name.toLowerCase();
87
+ }
88
+ async save() {
89
+ const qb = this.createQueryBuilder();
90
+ if (this.$_isPersisted) {
91
+ qb.update(this._changedValues)
92
+ // @ts-ignore
93
+ .where({ id: this._oldValues.id });
94
+ }
95
+ else {
96
+ qb.insert(this._oldValues);
97
+ }
98
+ await qb.execute();
99
+ this._oldValues = {
100
+ ...this._oldValues,
101
+ ...this._changedValues,
102
+ };
103
+ this._changedValues = {};
104
+ }
105
+ }
106
+ //# sourceMappingURL=base-entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-entity.js","sourceRoot":"","sources":["../../src/domain/base-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,OAAgB,UAAU;IAK9B;QAJQ,eAAU,GAAQ,EAAE,CAAC;QACrB,mBAAc,GAAQ,EAAE,CAAC;QACzB,kBAAa,GAAY,KAAK,CAAC;QAGrC,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;YACrB,GAAG,CAAC,MAAW,EAAE,CAAS,EAAE,QAAa;gBAEvC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;oBACrB,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;oBACrB,OAAO,IAAI,CAAC;iBACb;gBAED,sFAAsF;gBACtF,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;oBACzB,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;iBACjC;gBAED,0EAA0E;gBAC1E,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;oBACrC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;iBACrC;gBAED,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;gBAErB,OAAO,IA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a,CAAC;aAC7B,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC;aACvB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;aACpB,OAAO,CAAC,OAAO,EAAE,OAAmB,CAAC,CAAC;QAEzC,OAAO,OAAO,CAAC,mBAAmB,EAAE,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAEjB,KAA6B;QAE7B,OAAO,IAAI,CAAC,kBAAkB,EAAK;aAChC,MAAM,CAAC,KAAK,CAAC;aACb,2BAA2B,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,YAAY;QACjB,IAAI,WAAW,IAAI,IAAI,EAAE;YACvB,OAAQ,IAAY,CAAC,SAAS,CAAC;SAChC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,EAAE,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAA;QAEpC,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC;gBAC5B,aAAa;iBACZ,KAAK,CAAC,EAAC,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,EAAC,CAAC,CAAA;SACnC;aAAM;YACL,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SAC3B;QAED,MAAM,EAAE,CAAC,OAAO,EAAE,CAAA;QAElB,IAAI,CAAC,UAAU,GAAG;YAChB,GAAG,IAAI,CAAC,UAAU;YAClB,GAAG,IAAI,CAAC,cAAc;SACvB,CAAA;QACD,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;IAC1B,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export declare class ArrayCollection<T extends object, O extends object> {
2
+ getItems(): T[];
3
+ }
4
+ export declare class Collection<T extends object, O extends object = object> extends ArrayCollection<T, O> {
5
+ constructor(owner: O, items?: T[], initialized?: boolean);
6
+ }
@@ -0,0 +1,11 @@
1
+ export class ArrayCollection {
2
+ getItems() {
3
+ return [];
4
+ }
5
+ }
6
+ export class Collection extends ArrayCollection {
7
+ constructor(owner, items, initialized = true) {
8
+ super();
9
+ }
10
+ }
11
+ //# sourceMappingURL=collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/domain/collection.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IAC1B,QAAQ;QACN,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AACD,MAAM,OAAO,UAAwD,SAAQ,eAAqB;IAChG,YAAY,KAAQ,EAAE,KAAW,EAAE,WAAW,GAAG,IAAI;QACnD,KAAK,EAAE,CAAC;IACV,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ import { PropertyOptions } from '../decorators/property.decorator';
2
+ import { Relationship, SnapshotIndexInfo, SnapshotTable } from '../driver/driver.interface';
3
+ export type Property = {
4
+ options: PropertyOptions;
5
+ type: Function;
6
+ };
7
+ export type Options = {
8
+ showProperties: {
9
+ [key: string]: Property;
10
+ };
11
+ hideProperties: string[];
12
+ indexes?: SnapshotIndexInfo[];
13
+ relations: Relationship<any>[];
14
+ tableName: string;
15
+ schema?: string;
16
+ };
17
+ export declare class EntityStorage {
18
+ static instance: EntityStorage;
19
+ private entities;
20
+ constructor();
21
+ add(entity: {
22
+ target: Function;
23
+ options: any;
24
+ }, properties: {
25
+ [key: string]: Property;
26
+ }, relations: Relationship<any>[]): void;
27
+ get(entity: Function): Options | undefined;
28
+ entries(): IterableIterator<[Function, Options]>;
29
+ static getInstance(): EntityStorage;
30
+ snapshot(values: Options): Promise<SnapshotTable>;
31
+ private snapshotColumns;
32
+ private snapshotIndexes;
33
+ private getFkType;
34
+ /**
35
+ * If fkKey is null, return the primary key of the entity
36
+ * @private
37
+ * @param relationShip
38
+ */
39
+ private getFkKey;
40
+ }
@@ -0,0 +1,137 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var EntityStorage_1;
11
+ import { Metadata, Service } from '@cheetah.js/core';
12
+ import { getDefaultLength } from '../utils';
13
+ let EntityStorage = EntityStorage_1 = class EntityStorage {
14
+ constructor() {
15
+ this.entities = new Map();
16
+ EntityStorage_1.instance = this;
17
+ }
18
+ add(entity, properties, relations) {
19
+ const entityName = entity.options?.tableName || entity.target.name.toLowerCase();
20
+ const indexes = Metadata.get('indexes', entity.target) || [];
21
+ this.entities.set(entity.target, {
22
+ showProperties: properties,
23
+ hideProperties: [],
24
+ relations,
25
+ indexes: indexes.map((index) => {
26
+ return {
27
+ table: entityName,
28
+ indexName: index.name.replace('[TABLE]', entityName),
29
+ columnName: index.properties.join(','),
30
+ };
31
+ }),
32
+ tableName: entityName,
33
+ ...entity.options
34
+ });
35
+ }
36
+ get(entity) {
37
+ return this.entities.get(entity);
38
+ }
39
+ entries() {
40
+ return this.entities.entries();
41
+ }
42
+ static getInstance() {
43
+ return EntityStorage_1.instance;
44
+ }
45
+ async snapshot(values) {
46
+ return {
47
+ tableName: values.tableName,
48
+ schema: values.schema || 'public',
49
+ indexes: values.indexes || [],
50
+ columns: this.snapshotColumns(values),
51
+ };
52
+ }
53
+ snapshotColumns(values) {
54
+ let properties = Object.entries(values.showProperties).map(([key, value]) => {
55
+ return {
56
+ name: key,
57
+ type: value.type.name,
58
+ nullable: value.options?.nullable,
59
+ default: value.options?.default,
60
+ primary: value.options?.isPrimary,
61
+ unique: value.options?.unique,
62
+ length: value.options?.length,
63
+ };
64
+ });
65
+ // @ts-ignore
66
+ let relations = values.relations && values.relations.map((relation) => {
67
+ const type = this.getFkType(relation);
68
+ return {
69
+ name: relation.propertyKey,
70
+ type,
71
+ nullable: relation.nullable,
72
+ unique: relation.unique,
73
+ length: relation.length || getDefaultLength(type),
74
+ default: relation.default,
75
+ primary: relation.isPrimary,
76
+ foreignKeys: [
77
+ {
78
+ referencedColumnName: this.getFkKey(relation),
79
+ referencedTableName: this.get(relation.entity()).tableName,
80
+ }
81
+ ]
82
+ };
83
+ });
84
+ if (!relations) {
85
+ relations = [];
86
+ }
87
+ if (!properties) {
88
+ properties = [];
89
+ }
90
+ return [...properties, ...relations];
91
+ }
92
+ snapshotIndexes(values) {
93
+ return Object.entries(values.showProperties).map(([key, value]) => {
94
+ return {
95
+ indexName: key,
96
+ columnName: key,
97
+ table: values.tableName,
98
+ };
99
+ });
100
+ }
101
+ getFkType(relation) {
102
+ const entity = this.get(relation.entity());
103
+ if (!entity) {
104
+ return 'unknown';
105
+ }
106
+ return entity.showProperties[this.getFkKey(relation)].type.name;
107
+ }
108
+ /**
109
+ * If fkKey is null, return the primary key of the entity
110
+ * @private
111
+ * @param relationShip
112
+ */
113
+ getFkKey(relationShip) {
114
+ // se for nullable, deverá retornar o primary key da entidade target
115
+ if (typeof relationShip.fkKey === 'undefined') {
116
+ const entity = this.entities.get(relationShip.entity());
117
+ const property = Object.entries(entity.showProperties).find(([key, value]) => value.options.isPrimary === true);
118
+ if (!property) {
119
+ throw new Error(`Entity ${entity.tableName} does not have a primary key`);
120
+ }
121
+ return property[0];
122
+ }
123
+ // se o fkKey é uma função, ele retornará a propriedade da entidade que é a chave estrangeira
124
+ // precisamos pegar o nome dessa propriedade
125
+ if (typeof relationShip.fkKey === 'string') {
126
+ return relationShip.fkKey;
127
+ }
128
+ const match = /\.(?<propriedade>[\w]+)/.exec(relationShip.fkKey.toString());
129
+ return match ? match.groups.propriedade : '';
130
+ }
131
+ };
132
+ EntityStorage = EntityStorage_1 = __decorate([
133
+ Service(),
134
+ __metadata("design:paramtypes", [])
135
+ ], EntityStorage);
136
+ export { EntityStorage };
137
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../src/domain/entities.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAiBrC,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAKxB;QAFQ,aAAQ,GAA2B,IAAI,GAAG,EAAE,CAAC;QAGnD,eAAa,CAAC,QAAQ,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,GAAG,CAAC,MAA0C,EAAE,UAAqC,EAAE,SAA8B;QACnH,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjF,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE;YAC/B,cAAc,EAAE,UAAU;YAC1B,cAAc,EAAE,EAAE;YAClB,SAAS;YACT,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAA2C,EAAE,EAAE;gBACnE,OAAO;oBACL,KAAK,EAAE,UAAU;oBACjB,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC;oBACpD,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;iBACvC,CAAA;YACH,CAAC,C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class Reference {
2
+ constructor(entity) {
3
+ this.entity = entity;
4
+ console.log('Reference constructor');
5
+ }
6
+ }
7
+ //# sourceMappingURL=reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference.js","sourceRoot":"","sources":["../../src/domain/reference.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAS;IACpB,YAAoB,MAAS;QAAT,WAAM,GAAN,MAAM,CAAG;QAC3B,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;IACtC,CAAC;CACF"}