@danceroutine/tango-orm 0.1.0 → 1.0.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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +104 -0
  3. package/dist/{PostgresAdapter-_X36-mLL.js → PostgresAdapter-C9a1XJRx.js} +31 -7
  4. package/dist/PostgresAdapter-C9a1XJRx.js.map +1 -0
  5. package/dist/PostgresAdapter-CBc1u8eT.js +3 -0
  6. package/dist/SqliteAdapter-BJKNxCvS.js +3 -0
  7. package/dist/SqliteAdapter-Dp6VRXmz.js +118 -0
  8. package/dist/SqliteAdapter-Dp6VRXmz.js.map +1 -0
  9. package/dist/connection/adapters/Adapter.d.ts +9 -0
  10. package/dist/connection/adapters/AdapterRegistry.d.ts +28 -1
  11. package/dist/connection/adapters/dialects/PostgresAdapter.d.ts +10 -1
  12. package/dist/connection/adapters/dialects/SqliteAdapter.d.ts +11 -1
  13. package/dist/connection/clients/DBClient.d.ts +8 -0
  14. package/dist/connection/clients/dialects/PostgresClient.d.ts +22 -1
  15. package/dist/connection/clients/dialects/SqliteClient.d.ts +26 -1
  16. package/dist/connection/index.js +3 -3
  17. package/dist/{connection-DytAsjC9.js → connection-CVvycXus.js} +21 -6
  18. package/dist/connection-CVvycXus.js.map +1 -0
  19. package/dist/index.d.ts +7 -4
  20. package/dist/index.js +9 -8
  21. package/dist/manager/ManagerLike.d.ts +15 -0
  22. package/dist/manager/ModelManager.d.ts +48 -0
  23. package/dist/manager/index.d.ts +6 -0
  24. package/dist/manager/index.js +8 -0
  25. package/dist/manager/internal/MutationCompiler.d.ts +15 -0
  26. package/dist/manager/internal/RuntimeBoundClient.d.ts +16 -0
  27. package/dist/manager/registerModelObjects.d.ts +5 -0
  28. package/dist/manager-D6tU8xTO.js +13 -0
  29. package/dist/manager-D6tU8xTO.js.map +1 -0
  30. package/dist/query/QBuilder.d.ts +18 -0
  31. package/dist/query/QuerySet.d.ts +60 -9
  32. package/dist/query/compiler/QueryCompiler.d.ts +19 -2
  33. package/dist/query/domain/{RepositoryMeta.d.ts → TableMeta.d.ts} +1 -1
  34. package/dist/query/domain/index.d.ts +1 -1
  35. package/dist/query/index.d.ts +2 -2
  36. package/dist/query/index.js +1 -2
  37. package/dist/query-wnl4h2o7.js +671 -0
  38. package/dist/query-wnl4h2o7.js.map +1 -0
  39. package/dist/registerModelObjects-emX7Hja9.js +354 -0
  40. package/dist/registerModelObjects-emX7Hja9.js.map +1 -0
  41. package/dist/runtime/TangoRuntime.d.ts +34 -0
  42. package/dist/runtime/defaultRuntime.d.ts +13 -0
  43. package/dist/runtime/index.d.ts +13 -0
  44. package/dist/runtime/index.js +8 -0
  45. package/dist/runtime-7U5_XDad.js +17 -0
  46. package/dist/runtime-7U5_XDad.js.map +1 -0
  47. package/dist/transaction/UnitOfWork.d.ts +21 -3
  48. package/dist/transaction/index.js +1 -1
  49. package/dist/{transaction-DIGJnp19.js → transaction-DooTMuAl.js} +29 -11
  50. package/dist/transaction-DooTMuAl.js.map +1 -0
  51. package/dist/validation/OrmSqlSafetyAdapter.d.ts +22 -0
  52. package/dist/validation/SQLValidationEngine.d.ts +51 -0
  53. package/dist/validation/SqlValidationPlan.d.ts +42 -0
  54. package/dist/validation/index.d.ts +3 -0
  55. package/package.json +81 -74
  56. package/dist/PostgresAdapter-DCF8T4vh.js +0 -3
  57. package/dist/PostgresAdapter-_X36-mLL.js.map +0 -1
  58. package/dist/QuerySet-BzR5QzGi.js +0 -411
  59. package/dist/QuerySet-BzR5QzGi.js.map +0 -1
  60. package/dist/SqliteAdapter-CBnxCznk.js +0 -3
  61. package/dist/SqliteAdapter-J03fEjmr.js +0 -70
  62. package/dist/SqliteAdapter-J03fEjmr.js.map +0 -1
  63. package/dist/connection/clients/DBClient.js +0 -1
  64. package/dist/connection/clients/dialects/PostgresClient.js +0 -32
  65. package/dist/connection/clients/dialects/SqliteClient.js +0 -44
  66. package/dist/connection-DytAsjC9.js.map +0 -1
  67. package/dist/query/QuerySet.js +0 -108
  68. package/dist/query/compiler/QueryCompiler.js +0 -183
  69. package/dist/query/domain/CompiledQuery.js +0 -1
  70. package/dist/query/domain/WhereClause.js +0 -1
  71. package/dist/query-CQbvLeuh.js +0 -21
  72. package/dist/query-CQbvLeuh.js.map +0 -1
  73. package/dist/repository/Repository.d.ts +0 -40
  74. package/dist/repository/Repository.js +0 -100
  75. package/dist/repository/index.d.ts +0 -4
  76. package/dist/repository/index.js +0 -4
  77. package/dist/repository-DaRvsfjs.js +0 -78
  78. package/dist/repository-DaRvsfjs.js.map +0 -1
  79. package/dist/transaction-DIGJnp19.js.map +0 -1
@@ -21,11 +21,29 @@ export declare class UnitOfWork {
21
21
  readonly __tangoBrand: typeof UnitOfWork.BRAND;
22
22
  protected client: DBClient;
23
23
  protected isActive: boolean;
24
- static isUnitOfWork(value: unknown): value is UnitOfWork;
25
24
  constructor(client: DBClient);
25
+ /**
26
+ * Narrow an unknown value to `UnitOfWork`.
27
+ */
28
+ static isUnitOfWork(value: unknown): value is UnitOfWork;
29
+ /**
30
+ * Convenience factory that constructs and begins a unit of work.
31
+ */
32
+ static start(client: DBClient): Promise<UnitOfWork>;
33
+ /**
34
+ * Begin a transaction if one is not already active.
35
+ */
26
36
  begin(): Promise<void>;
37
+ /**
38
+ * Commit the active transaction.
39
+ */
27
40
  commit(): Promise<void>;
28
- rollback(): Promise<void>;
41
+ /**
42
+ * Return the underlying database client.
43
+ */
29
44
  getClient(): DBClient;
30
- static start(client: DBClient): Promise<UnitOfWork>;
45
+ /**
46
+ * Roll back the active transaction.
47
+ */
48
+ rollback(): Promise<void>;
31
49
  }
@@ -1,3 +1,3 @@
1
- import { UnitOfWork } from "../transaction-DIGJnp19.js";
1
+ import { UnitOfWork } from "../transaction-DooTMuAl.js";
2
2
 
3
3
  export { UnitOfWork };
@@ -6,38 +6,56 @@ var UnitOfWork = class UnitOfWork {
6
6
  __tangoBrand = UnitOfWork.BRAND;
7
7
  client;
8
8
  isActive = false;
9
+ constructor(client) {
10
+ this.client = client;
11
+ }
12
+ /**
13
+ * Narrow an unknown value to `UnitOfWork`.
14
+ */
9
15
  static isUnitOfWork(value) {
10
16
  return typeof value === "object" && value !== null && value.__tangoBrand === UnitOfWork.BRAND;
11
17
  }
12
- constructor(client) {
13
- this.client = client;
18
+ /**
19
+ * Convenience factory that constructs and begins a unit of work.
20
+ */
21
+ static async start(client) {
22
+ const uow = new UnitOfWork(client);
23
+ await uow.begin();
24
+ return uow;
14
25
  }
26
+ /**
27
+ * Begin a transaction if one is not already active.
28
+ */
15
29
  async begin() {
16
30
  if (!this.isActive) {
17
31
  await this.client.begin();
18
32
  this.isActive = true;
19
33
  }
20
34
  }
35
+ /**
36
+ * Commit the active transaction.
37
+ */
21
38
  async commit() {
22
39
  if (this.isActive) {
23
40
  await this.client.commit();
24
41
  this.isActive = false;
25
42
  }
26
43
  }
44
+ /**
45
+ * Return the underlying database client.
46
+ */
47
+ getClient() {
48
+ return this.client;
49
+ }
50
+ /**
51
+ * Roll back the active transaction.
52
+ */
27
53
  async rollback() {
28
54
  if (this.isActive) {
29
55
  await this.client.rollback();
30
56
  this.isActive = false;
31
57
  }
32
58
  }
33
- getClient() {
34
- return this.client;
35
- }
36
- static async start(client) {
37
- const uow = new UnitOfWork(client);
38
- await uow.begin();
39
- return uow;
40
- }
41
59
  };
42
60
 
43
61
  //#endregion
@@ -47,4 +65,4 @@ __export(transaction_exports, { UnitOfWork: () => UnitOfWork });
47
65
 
48
66
  //#endregion
49
67
  export { UnitOfWork, transaction_exports };
50
- //# sourceMappingURL=transaction-DIGJnp19.js.map
68
+ //# sourceMappingURL=transaction-DooTMuAl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-DooTMuAl.js","names":["client: DBClient","value: unknown"],"sources":["../src/transaction/UnitOfWork.ts","../src/transaction/index.ts"],"sourcesContent":["import type { DBClient } from '../connection/clients/DBClient';\n\n/**\n * Unit of Work pattern implementation for managing database transactions.\n * Ensures that a set of operations either all succeed or all fail together.\n *\n * @example\n * ```typescript\n * const uow = await UnitOfWork.start(dbClient);\n * try {\n * await userRepo.create({ email: 'test@example.com' });\n * await postRepo.create({ title: 'Hello' });\n * await uow.commit();\n * } catch (error) {\n * await uow.rollback();\n * throw error;\n * }\n * ```\n */\nexport class UnitOfWork {\n static readonly BRAND = 'tango.orm.unit_of_work' as const;\n readonly __tangoBrand: typeof UnitOfWork.BRAND = UnitOfWork.BRAND;\n protected client: DBClient;\n protected isActive = false;\n\n constructor(client: DBClient) {\n this.client = client;\n }\n\n /**\n * Narrow an unknown value to `UnitOfWork`.\n */\n static isUnitOfWork(value: unknown): value is UnitOfWork {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === UnitOfWork.BRAND\n );\n }\n\n /**\n * Convenience factory that constructs and begins a unit of work.\n */\n static async start(client: DBClient): Promise<UnitOfWork> {\n const uow = new UnitOfWork(client);\n await uow.begin();\n return uow;\n }\n\n /**\n * Begin a transaction if one is not already active.\n */\n async begin(): Promise<void> {\n if (!this.isActive) {\n await this.client.begin();\n this.isActive = true;\n }\n }\n\n /**\n * Commit the active transaction.\n */\n async commit(): Promise<void> {\n if (this.isActive) {\n await this.client.commit();\n this.isActive = false;\n }\n }\n\n /**\n * Return the underlying database client.\n */\n getClient(): DBClient {\n return this.client;\n }\n\n /**\n * Roll back the active transaction.\n */\n async rollback(): Promise<void> {\n if (this.isActive) {\n await this.client.rollback();\n this.isActive = false;\n }\n }\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { UnitOfWork } from './UnitOfWork';\n"],"mappings":";;;IAmBa,aAAN,MAAM,WAAW;CACpB,OAAgB,QAAQ;CACxB,eAAiD,WAAW;CAC5D;CACA,WAAqB;CAErB,YAAYA,QAAkB;AAC1B,OAAK,SAAS;CACjB;;;;CAKD,OAAO,aAAaC,OAAqC;AACrD,gBACW,UAAU,YACjB,UAAU,QACT,MAAqC,iBAAiB,WAAW;CAEzE;;;;CAKD,aAAa,MAAMD,QAAuC;EACtD,MAAM,MAAM,IAAI,WAAW;AAC3B,QAAM,IAAI,OAAO;AACjB,SAAO;CACV;;;;CAKD,MAAM,QAAuB;AACzB,OAAK,KAAK,UAAU;AAChB,SAAM,KAAK,OAAO,OAAO;AACzB,QAAK,WAAW;EACnB;CACJ;;;;CAKD,MAAM,SAAwB;AAC1B,MAAI,KAAK,UAAU;AACf,SAAM,KAAK,OAAO,QAAQ;AAC1B,QAAK,WAAW;EACnB;CACJ;;;;CAKD,YAAsB;AAClB,SAAO,KAAK;CACf;;;;CAKD,MAAM,WAA0B;AAC5B,MAAI,KAAK,UAAU;AACf,SAAM,KAAK,OAAO,UAAU;AAC5B,QAAK,WAAW;EACnB;CACJ;AACJ"}
@@ -0,0 +1,22 @@
1
+ import { SqlSafetyEngine } from '@danceroutine/tango-core';
2
+ import type { SQLValidationEngine, ValidatedDeleteSqlPlan, ValidatedInsertSqlPlan, ValidatedSelectSqlPlan, ValidatedUpdateSqlPlan } from './SQLValidationEngine';
3
+ import type { DeleteSqlValidationPlan, InsertSqlValidationPlan, SelectSqlValidationPlan, UpdateSqlValidationPlan } from './SqlValidationPlan';
4
+ /**
5
+ * ORM-local adapter that translates query validation plans into the
6
+ * shared Tango SQL safety engine.
7
+ */
8
+ export declare class OrmSqlSafetyAdapter implements SQLValidationEngine {
9
+ private readonly engine;
10
+ static readonly BRAND: "tango.orm.orm_sql_safety_adapter";
11
+ readonly __tangoBrand: typeof OrmSqlSafetyAdapter.BRAND;
12
+ constructor(engine?: SqlSafetyEngine);
13
+ validate(plan: SelectSqlValidationPlan): ValidatedSelectSqlPlan;
14
+ validate(plan: InsertSqlValidationPlan): ValidatedInsertSqlPlan;
15
+ validate(plan: UpdateSqlValidationPlan): ValidatedUpdateSqlPlan;
16
+ validate(plan: DeleteSqlValidationPlan): ValidatedDeleteSqlPlan;
17
+ private validateTableMeta;
18
+ private validateRelationMeta;
19
+ private validateFilterKey;
20
+ private resolveColumn;
21
+ private resolveRelation;
22
+ }
@@ -0,0 +1,51 @@
1
+ import type { RelationMeta, LookupType } from '../query';
2
+ import type { DeleteSqlValidationPlan, InsertSqlValidationPlan, SelectSqlValidationPlan, SqlValidationPlan, UpdateSqlValidationPlan } from './SqlValidationPlan';
3
+ export type ValidatedRelationMeta = RelationMeta & {
4
+ table: string;
5
+ targetPk: string;
6
+ alias: string;
7
+ localKey?: string;
8
+ foreignKey?: string;
9
+ };
10
+ export type ValidatedTableMeta = {
11
+ table: string;
12
+ pk: string;
13
+ columns: Record<string, string>;
14
+ relations?: Record<string, ValidatedRelationMeta>;
15
+ };
16
+ export type ValidatedFilterDescriptor = {
17
+ rawKey: string;
18
+ field: string;
19
+ lookup: LookupType;
20
+ qualifiedColumn: string;
21
+ };
22
+ export type ValidatedSelectSqlPlan = {
23
+ kind: 'select';
24
+ meta: ValidatedTableMeta;
25
+ selectFields: Record<string, string>;
26
+ filterKeys: Record<string, ValidatedFilterDescriptor>;
27
+ orderFields: Record<string, string>;
28
+ relations: Record<string, ValidatedRelationMeta>;
29
+ };
30
+ export type ValidatedInsertSqlPlan = {
31
+ kind: 'insert';
32
+ meta: ValidatedTableMeta;
33
+ writeKeys: string[];
34
+ };
35
+ export type ValidatedUpdateSqlPlan = {
36
+ kind: 'update';
37
+ meta: ValidatedTableMeta;
38
+ writeKeys: string[];
39
+ };
40
+ export type ValidatedDeleteSqlPlan = {
41
+ kind: 'delete';
42
+ meta: ValidatedTableMeta;
43
+ };
44
+ export type ValidatedSqlPlan = ValidatedSelectSqlPlan | ValidatedInsertSqlPlan | ValidatedUpdateSqlPlan | ValidatedDeleteSqlPlan;
45
+ export interface SQLValidationEngine {
46
+ validate(plan: SelectSqlValidationPlan): ValidatedSelectSqlPlan;
47
+ validate(plan: InsertSqlValidationPlan): ValidatedInsertSqlPlan;
48
+ validate(plan: UpdateSqlValidationPlan): ValidatedUpdateSqlPlan;
49
+ validate(plan: DeleteSqlValidationPlan): ValidatedDeleteSqlPlan;
50
+ validate(plan: SqlValidationPlan): ValidatedSqlPlan;
51
+ }
@@ -0,0 +1,42 @@
1
+ import type { TableMeta } from '../query/domain/TableMeta';
2
+ /**
3
+ * Validation request for read/query compilation.
4
+ *
5
+ * The ORM uses this plan to validate selected fields, filter keys, ordering,
6
+ * and relation names before SQL is assembled.
7
+ */
8
+ export type SelectSqlValidationPlan = {
9
+ kind: 'select';
10
+ meta: TableMeta;
11
+ selectFields?: readonly string[];
12
+ filterKeys?: readonly string[];
13
+ orderFields?: readonly string[];
14
+ relationNames?: readonly string[];
15
+ };
16
+ /**
17
+ * Validation request for insert statements.
18
+ */
19
+ export type InsertSqlValidationPlan = {
20
+ kind: 'insert';
21
+ meta: TableMeta;
22
+ writeKeys: readonly string[];
23
+ };
24
+ /**
25
+ * Validation request for update statements.
26
+ */
27
+ export type UpdateSqlValidationPlan = {
28
+ kind: 'update';
29
+ meta: TableMeta;
30
+ writeKeys: readonly string[];
31
+ };
32
+ /**
33
+ * Validation request for delete statements.
34
+ */
35
+ export type DeleteSqlValidationPlan = {
36
+ kind: 'delete';
37
+ meta: TableMeta;
38
+ };
39
+ /**
40
+ * ORM-local SQL validation requests routed through `OrmSqlSafetyAdapter`.
41
+ */
42
+ export type SqlValidationPlan = SelectSqlValidationPlan | InsertSqlValidationPlan | UpdateSqlValidationPlan | DeleteSqlValidationPlan;
@@ -0,0 +1,3 @@
1
+ export * from './OrmSqlSafetyAdapter';
2
+ export type * from './SQLValidationEngine';
3
+ export type { DeleteSqlValidationPlan, InsertSqlValidationPlan, SelectSqlValidationPlan, SqlValidationPlan, UpdateSqlValidationPlan, } from './SqlValidationPlan';
package/package.json CHANGED
@@ -1,82 +1,89 @@
1
1
  {
2
- "name": "@danceroutine/tango-orm",
3
- "version": "0.1.0",
4
- "description": "QuerySet, Repository, UnitOfWork, and database adapters for Tango",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- },
13
- "./query": {
14
- "types": "./dist/query/index.d.ts",
15
- "import": "./dist/query/index.js"
16
- },
17
- "./connection": {
18
- "types": "./dist/connection/index.d.ts",
19
- "import": "./dist/connection/index.js"
20
- },
21
- "./transaction": {
22
- "types": "./dist/transaction/index.d.ts",
23
- "import": "./dist/transaction/index.js"
24
- },
25
- "./repository": {
26
- "types": "./dist/repository/index.d.ts",
27
- "import": "./dist/repository/index.js"
28
- }
2
+ "name": "@danceroutine/tango-orm",
3
+ "version": "1.0.0",
4
+ "description": "Model-first querying, runtime-managed database access, and transactions for Tango",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
29
12
  },
30
- "files": [
31
- "dist"
32
- ],
33
- "scripts": {
34
- "build": "tsdown",
35
- "test": "vitest run --coverage",
36
- "test:integration": "vitest run src/tests/integration",
37
- "test:watch": "vitest",
38
- "typecheck": "tsc --noEmit"
13
+ "./query": {
14
+ "types": "./dist/query/index.d.ts",
15
+ "import": "./dist/query/index.js"
39
16
  },
40
- "keywords": [
41
- "tango",
42
- "orm",
43
- "queryset",
44
- "repository",
45
- "database"
46
- ],
47
- "author": "Pedro Del Moral Lopez",
48
- "license": "MIT",
49
- "repository": {
50
- "type": "git",
51
- "url": "https://github.com/danceroutine/tango.git",
52
- "directory": "packages/orm"
17
+ "./connection": {
18
+ "types": "./dist/connection/index.d.ts",
19
+ "import": "./dist/connection/index.js"
53
20
  },
54
- "dependencies": {
55
- "@danceroutine/tango-config": "workspace:*",
56
- "@danceroutine/tango-core": "workspace:*"
21
+ "./transaction": {
22
+ "types": "./dist/transaction/index.d.ts",
23
+ "import": "./dist/transaction/index.js"
57
24
  },
58
- "peerDependencies": {
59
- "pg": "^8.13.1",
60
- "better-sqlite3": "^11.7.0"
25
+ "./runtime": {
26
+ "types": "./dist/runtime/index.d.ts",
27
+ "import": "./dist/runtime/index.js"
61
28
  },
62
- "peerDependenciesMeta": {
63
- "pg": {
64
- "optional": true
65
- },
66
- "better-sqlite3": {
67
- "optional": true
68
- }
29
+ "./manager": {
30
+ "types": "./dist/manager/index.d.ts",
31
+ "import": "./dist/manager/index.js"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "keywords": [
38
+ "tango",
39
+ "orm",
40
+ "queryset",
41
+ "database"
42
+ ],
43
+ "author": "Pedro Del Moral Lopez",
44
+ "license": "MIT",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/danceroutine/tango.git",
48
+ "directory": "packages/orm"
49
+ },
50
+ "dependencies": {
51
+ "zod": "^4.0.0",
52
+ "@danceroutine/tango-config": "1.0.0",
53
+ "@danceroutine/tango-core": "1.0.0",
54
+ "@danceroutine/tango-schema": "1.0.0"
55
+ },
56
+ "peerDependencies": {
57
+ "pg": "^8.13.1",
58
+ "better-sqlite3": "^11.7.0"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "pg": {
62
+ "optional": true
69
63
  },
70
- "devDependencies": {
71
- "@danceroutine/tango-migrations": "workspace:*",
72
- "@danceroutine/tango-testing": "workspace:*",
73
- "@types/better-sqlite3": "^7.6.12",
74
- "@types/node": "^22.9.0",
75
- "@types/pg": "^8.11.10",
76
- "better-sqlite3": "^11.7.0",
77
- "pg": "^8.13.1",
78
- "tsdown": "^0.4.0",
79
- "typescript": "^5.6.3",
80
- "vitest": "^4.0.6"
64
+ "better-sqlite3": {
65
+ "optional": true
81
66
  }
82
- }
67
+ },
68
+ "devDependencies": {
69
+ "@types/better-sqlite3": "^7.6.12",
70
+ "@types/node": "^22.9.0",
71
+ "@types/pg": "^8.11.10",
72
+ "better-sqlite3": "^11.7.0",
73
+ "pg": "^8.13.1",
74
+ "tsdown": "^0.4.0",
75
+ "typescript": "^5.6.3",
76
+ "vitest": "^4.0.6",
77
+ "@danceroutine/tango-migrations": "1.0.0",
78
+ "@danceroutine/tango-testing": "1.0.0"
79
+ },
80
+ "scripts": {
81
+ "build": "tsdown",
82
+ "test": "vitest run --coverage",
83
+ "test:integration": "vitest run src/tests/integration",
84
+ "test:watch": "vitest",
85
+ "typecheck": "pnpm run typecheck:prod && pnpm run typecheck:test",
86
+ "typecheck:prod": "tsc --noEmit -p tsconfig.json",
87
+ "typecheck:test": "tsc --noEmit -p tsconfig.tests.json"
88
+ }
89
+ }
@@ -1,3 +0,0 @@
1
- import { PostgresAdapter } from "./PostgresAdapter-_X36-mLL.js";
2
-
3
- export { PostgresAdapter };
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostgresAdapter-_X36-mLL.js","names":["value: unknown","pool: pg.Pool","client: pg.PoolClient","sql: string","params?: any[]","value: unknown","config: AdapterConfig"],"sources":["../src/connection/clients/dialects/PostgresClient.ts","../src/connection/adapters/dialects/PostgresAdapter.ts"],"sourcesContent":["import type pg from 'pg';\nimport type { DBClient } from '../DBClient';\n\nexport class PostgresClient implements DBClient {\n static readonly BRAND = 'tango.orm.postgres_client' as const;\n readonly __tangoBrand: typeof PostgresClient.BRAND = PostgresClient.BRAND;\n\n static isPostgresClient(value: unknown): value is PostgresClient {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === PostgresClient.BRAND\n );\n }\n\n constructor(\n private pool: pg.Pool,\n private client: pg.PoolClient\n ) {}\n\n async query<T = any>(sql: string, params?: any[]): Promise<{ rows: T[] }> {\n const result = await this.client.query(sql, params);\n return { rows: result.rows as T[] };\n }\n\n async begin(): Promise<void> {\n await this.client.query('BEGIN');\n }\n\n async commit(): Promise<void> {\n await this.client.query('COMMIT');\n }\n\n async rollback(): Promise<void> {\n await this.client.query('ROLLBACK');\n }\n\n async close(): Promise<void> {\n this.client.release();\n await this.pool.end();\n }\n}\n","import pg from 'pg';\nimport type { Adapter, AdapterConfig } from '../Adapter';\nimport type { DBClient } from '../../clients/DBClient';\nimport { PostgresClient } from '../../clients/dialects/PostgresClient';\n\nconst { Pool } = pg;\nexport class PostgresAdapter implements Adapter {\n static readonly BRAND = 'tango.orm.postgres_adapter' as const;\n readonly __tangoBrand: typeof PostgresAdapter.BRAND = PostgresAdapter.BRAND;\n readonly name = 'postgres';\n\n static isPostgresAdapter(value: unknown): value is PostgresAdapter {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === PostgresAdapter.BRAND\n );\n }\n\n /**\n * Declares capabilities of this database adapter.\n * Used by the migration runner and query compiler to determine which\n * SQL features can be safely used:\n * - transactionalDDL: Postgres supports DDL inside transactions (safe rollback of schema changes)\n * - concurrentIndex: Supports CREATE INDEX CONCURRENTLY (non-blocking index builds)\n * - validateForeignKeys: Supports deferred FK validation via NOT VALID + VALIDATE CONSTRAINT\n */\n readonly features = {\n transactionalDDL: true,\n concurrentIndex: true,\n validateForeignKeys: true,\n };\n\n async connect(config: AdapterConfig): Promise<DBClient> {\n const pool = new Pool({\n connectionString: config.url,\n host: config.host,\n port: config.port,\n database: config.database,\n user: config.user,\n password: config.password,\n max: config.maxConnections || 10,\n });\n\n const client = await pool.connect();\n return new PostgresClient(pool, client);\n }\n}\n"],"mappings":";;;IAGa,iBAAN,MAAM,eAAmC;CAC5C,OAAgB,QAAQ;CACxB,eAAqD,eAAe;CAEpE,OAAO,iBAAiBA,OAAyC;AAC7D,gBACW,UAAU,YACjB,UAAU,QACT,MAAqC,iBAAiB,eAAe;CAE7E;CAED,YACYC,MACAC,QACV;AAAA,OAFU,OAAA;AAAA,OACA,SAAA;CACR;CAEJ,MAAM,MAAeC,KAAaC,QAAwC;EACtE,MAAM,SAAS,MAAM,KAAK,OAAO,MAAM,KAAK,OAAO;AACnD,SAAO,EAAE,MAAM,OAAO,KAAa;CACtC;CAED,MAAM,QAAuB;AACzB,QAAM,KAAK,OAAO,MAAM,QAAQ;CACnC;CAED,MAAM,SAAwB;AAC1B,QAAM,KAAK,OAAO,MAAM,SAAS;CACpC;CAED,MAAM,WAA0B;AAC5B,QAAM,KAAK,OAAO,MAAM,WAAW;CACtC;CAED,MAAM,QAAuB;AACzB,OAAK,OAAO,SAAS;AACrB,QAAM,KAAK,KAAK,KAAK;CACxB;AACJ;;;;ACpCD,MAAM,EAAE,MAAM,GAAG;IACJ,kBAAN,MAAM,gBAAmC;CAC5C,OAAgB,QAAQ;CACxB,eAAsD,gBAAgB;CACtE,OAAgB;CAEhB,OAAO,kBAAkBC,OAA0C;AAC/D,gBACW,UAAU,YACjB,UAAU,QACT,MAAqC,iBAAiB,gBAAgB;CAE9E;;;;;;;;;CAUD,WAAoB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;CACxB;CAED,MAAM,QAAQC,QAA0C;EACpD,MAAM,OAAO,IAAI,KAAK;GAClB,kBAAkB,OAAO;GACzB,MAAM,OAAO;GACb,MAAM,OAAO;GACb,UAAU,OAAO;GACjB,MAAM,OAAO;GACb,UAAU,OAAO;GACjB,KAAK,OAAO,kBAAkB;EACjC;EAED,MAAM,SAAS,MAAM,KAAK,SAAS;AACnC,SAAO,IAAI,eAAe,MAAM;CACnC;AACJ"}