@nathapp/nestjs-tenant-prisma 1.0.0 → 1.1.1

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/README.md CHANGED
@@ -29,13 +29,18 @@ timezone.
29
29
 
30
30
  ```ts
31
31
  import { Module } from '@nestjs/common';
32
- import { PrismaClient } from '@prisma/client';
32
+ import { PrismaPg } from '@prisma/adapter-pg'; // MySQL: PrismaMariaDb from '@prisma/adapter-mariadb' (host/port/user/password/database, no connectionString)
33
+ import { PrismaClient } from './generated/prisma/client'; // your generator `output`
33
34
  import { PrismaModule } from '@nathapp/nestjs-prisma';
34
35
  import { TenantPrismaModule } from '@nathapp/nestjs-tenant-prisma';
35
36
 
36
37
  @Module({
37
38
  imports: [
38
- PrismaModule.forRoot({ client: PrismaClient, transaction: true }),
39
+ PrismaModule.forRoot({
40
+ client: PrismaClient,
41
+ clientOptions: { adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL! }) },
42
+ transaction: true,
43
+ }),
39
44
  TenantPrismaModule.register(),
40
45
  ],
41
46
  })
@@ -83,7 +88,8 @@ which is exported from this package if you need to name the type.
83
88
 
84
89
  ## Transactions
85
90
 
86
- Multi-write flows need `PrismaModule.forRoot({ client: PrismaClient, transaction: true })`.
91
+ Multi-write flows need `PrismaModule.forRoot({ client: PrismaClient, transaction: true })`
92
+ with `PrismaClient` imported from your generated client (Prisma 7 `prisma-client` generator).
87
93
  Every repository resolves its client per operation from the `TRANSACTION_MANAGER`
88
94
  token, and the two `PrismaModule` registration paths fail differently when
89
95
  `transaction` is omitted:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nestjs-tenant-prisma",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Prisma adapter for @nathapp/nestjs-tenant",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && tsc -p tsconfig.json",
@@ -24,18 +24,18 @@
24
24
  "lib": "lib"
25
25
  },
26
26
  "dependencies": {
27
- "@nathapp/nestjs-tenant": "1.0.0",
28
- "@nathapp/nestjs-data": "^3.3.0 || ^4.0.2"
27
+ "@nathapp/nestjs-tenant": "1.1.0",
28
+ "@nathapp/nestjs-data": "^3.3.0 || ^4.0.3"
29
29
  },
30
30
  "devDependencies": {
31
- "@nathapp/nestjs-prisma": "^4.0.2",
31
+ "@nathapp/nestjs-prisma": "^4.1.0",
32
32
  "eslint": "^8.57.0",
33
33
  "typescript": "^5"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@nestjs/common": "^11.0.0 || ^12.1.0",
37
37
  "@nestjs/core": "^11.0.0 || ^12.1.0",
38
- "@nathapp/nestjs-prisma": "^3.3.0 || ^4.0.2",
39
- "@prisma/client": "^6.0.0"
38
+ "@nathapp/nestjs-prisma": "^4.1.0",
39
+ "@prisma/client": "^7.0.0"
40
40
  }
41
41
  }
package/AGENTS.md DELETED
@@ -1,71 +0,0 @@
1
- # Agent Instructions
2
-
3
- This file is auto-generated from `.nax/context.md`.
4
- DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
5
-
6
- These instructions apply to all AI coding agents in this project.
7
-
8
- ---
9
-
10
- ## Project Metadata
11
-
12
- > Auto-injected by `nax generate`
13
-
14
- **Project:** `@nathapp/nestjs-tenant-prisma`
15
-
16
- **Language:** TypeScript
17
-
18
- **Key dependencies:** @nathapp/nestjs-prisma, typescript
19
-
20
- ---
21
- # CLAUDE.md — @nathapp/nestjs-tenant-prisma
22
-
23
- Prisma adapter for `@nathapp/nestjs-tenant`. Implements `ITenantRepository` using `@prisma/client`.
24
-
25
- ## Status: ✅ Complete
26
-
27
- ## Wiring
28
-
29
- The consumer app registers Prisma with transactions enabled, then this adapter:
30
-
31
- ```typescript
32
- @Module({
33
- imports: [
34
- PrismaModule.forRoot({ client: PrismaClient, transaction: true, isGlobal: true }), // @nathapp/nestjs-prisma
35
- TenantModule.register({ resolver: HeaderTenantResolver }), // @nathapp/nestjs-tenant
36
- TenantPrismaModule.register(), // binds TENANT_REPOSITORY
37
- ],
38
- })
39
- export class AppModule {}
40
- ```
41
-
42
- `PrismaModule.forRoot({ transaction: true })` provides `TRANSACTION_MANAGER`; `PrismaTenantRepository` (extends `AbstractPrismaRepository`) resolves its client per operation from it, so tenant writes participate automatically in any `txManager.run(...)`.
43
-
44
- ## Implementation
45
-
46
- - `PrismaTenantRepository extends AbstractPrismaRepository<Tenant, any, string>` — inherits CRUD + pagination, adds `findBySlug` / `findByDomain` / `exists`.
47
- - `exists` uses `findById` (not `count`) because `AbstractPrismaRepository.count` maps criteria through `toPersistenceUpdate`, which does not include `id`.
48
-
49
- ## Dependencies
50
-
51
- - `@nathapp/nestjs-tenant` (workspace)
52
- - `@nathapp/nestjs-prisma` ^3.2.0 (peer) — provides `AbstractPrismaRepository`, `PrismaModule`
53
- - `@nathapp/nestjs-data` ^3.2.0 (transitive) — provides `TRANSACTION_MANAGER`, `ITransactionManager`
54
- - `@prisma/client` ^6.0.0 (peer)
55
-
56
- ## Schema conventions
57
-
58
- All `DateTime` fields in the consumer's `schema.prisma` for models backing this package MUST use `@db.Timestamptz(6)`:
59
-
60
- ```prisma
61
- createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
62
- updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
63
- ```
64
-
65
- This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is NOT correct for this platform.
66
-
67
- When migrating an existing database from bare `DateTime` columns:
68
- ```sql
69
- ALTER TABLE tenants ALTER COLUMN created_at TYPE TIMESTAMPTZ(6) USING created_at AT TIME ZONE 'UTC';
70
- ALTER TABLE tenants ALTER COLUMN updated_at TYPE TIMESTAMPTZ(6) USING updated_at AT TIME ZONE 'UTC';
71
- ```
package/CLAUDE.md DELETED
@@ -1,69 +0,0 @@
1
- # Project Context
2
-
3
- This file is auto-generated from `.nax/context.md`.
4
- DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
5
-
6
- ---
7
-
8
- ## Project Metadata
9
-
10
- > Auto-injected by `nax generate`
11
-
12
- **Project:** `@nathapp/nestjs-tenant-prisma`
13
-
14
- **Language:** TypeScript
15
-
16
- **Key dependencies:** @nathapp/nestjs-prisma, typescript
17
-
18
- ---
19
- # CLAUDE.md — @nathapp/nestjs-tenant-prisma
20
-
21
- Prisma adapter for `@nathapp/nestjs-tenant`. Implements `ITenantRepository` using `@prisma/client`.
22
-
23
- ## Status: ✅ Complete
24
-
25
- ## Wiring
26
-
27
- The consumer app registers Prisma with transactions enabled, then this adapter:
28
-
29
- ```typescript
30
- @Module({
31
- imports: [
32
- PrismaModule.forRoot({ client: PrismaClient, transaction: true, isGlobal: true }), // @nathapp/nestjs-prisma
33
- TenantModule.register({ resolver: HeaderTenantResolver }), // @nathapp/nestjs-tenant
34
- TenantPrismaModule.register(), // binds TENANT_REPOSITORY
35
- ],
36
- })
37
- export class AppModule {}
38
- ```
39
-
40
- `PrismaModule.forRoot({ transaction: true })` provides `TRANSACTION_MANAGER`; `PrismaTenantRepository` (extends `AbstractPrismaRepository`) resolves its client per operation from it, so tenant writes participate automatically in any `txManager.run(...)`.
41
-
42
- ## Implementation
43
-
44
- - `PrismaTenantRepository extends AbstractPrismaRepository<Tenant, any, string>` — inherits CRUD + pagination, adds `findBySlug` / `findByDomain` / `exists`.
45
- - `exists` uses `findById` (not `count`) because `AbstractPrismaRepository.count` maps criteria through `toPersistenceUpdate`, which does not include `id`.
46
-
47
- ## Dependencies
48
-
49
- - `@nathapp/nestjs-tenant` (workspace)
50
- - `@nathapp/nestjs-prisma` ^3.2.0 (peer) — provides `AbstractPrismaRepository`, `PrismaModule`
51
- - `@nathapp/nestjs-data` ^3.2.0 (transitive) — provides `TRANSACTION_MANAGER`, `ITransactionManager`
52
- - `@prisma/client` ^6.0.0 (peer)
53
-
54
- ## Schema conventions
55
-
56
- All `DateTime` fields in the consumer's `schema.prisma` for models backing this package MUST use `@db.Timestamptz(6)`:
57
-
58
- ```prisma
59
- createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
60
- updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
61
- ```
62
-
63
- This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is NOT correct for this platform.
64
-
65
- When migrating an existing database from bare `DateTime` columns:
66
- ```sql
67
- ALTER TABLE tenants ALTER COLUMN created_at TYPE TIMESTAMPTZ(6) USING created_at AT TIME ZONE 'UTC';
68
- ALTER TABLE tenants ALTER COLUMN updated_at TYPE TIMESTAMPTZ(6) USING updated_at AT TIME ZONE 'UTC';
69
- ```
package/GEMINI.md DELETED
@@ -1,69 +0,0 @@
1
- # Gemini CLI Context
2
-
3
- This file is auto-generated from `.nax/context.md`.
4
- DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
5
-
6
- ---
7
-
8
- ## Project Metadata
9
-
10
- > Auto-injected by `nax generate`
11
-
12
- **Project:** `@nathapp/nestjs-tenant-prisma`
13
-
14
- **Language:** TypeScript
15
-
16
- **Key dependencies:** @nathapp/nestjs-prisma, typescript
17
-
18
- ---
19
- # CLAUDE.md — @nathapp/nestjs-tenant-prisma
20
-
21
- Prisma adapter for `@nathapp/nestjs-tenant`. Implements `ITenantRepository` using `@prisma/client`.
22
-
23
- ## Status: ✅ Complete
24
-
25
- ## Wiring
26
-
27
- The consumer app registers Prisma with transactions enabled, then this adapter:
28
-
29
- ```typescript
30
- @Module({
31
- imports: [
32
- PrismaModule.forRoot({ client: PrismaClient, transaction: true, isGlobal: true }), // @nathapp/nestjs-prisma
33
- TenantModule.register({ resolver: HeaderTenantResolver }), // @nathapp/nestjs-tenant
34
- TenantPrismaModule.register(), // binds TENANT_REPOSITORY
35
- ],
36
- })
37
- export class AppModule {}
38
- ```
39
-
40
- `PrismaModule.forRoot({ transaction: true })` provides `TRANSACTION_MANAGER`; `PrismaTenantRepository` (extends `AbstractPrismaRepository`) resolves its client per operation from it, so tenant writes participate automatically in any `txManager.run(...)`.
41
-
42
- ## Implementation
43
-
44
- - `PrismaTenantRepository extends AbstractPrismaRepository<Tenant, any, string>` — inherits CRUD + pagination, adds `findBySlug` / `findByDomain` / `exists`.
45
- - `exists` uses `findById` (not `count`) because `AbstractPrismaRepository.count` maps criteria through `toPersistenceUpdate`, which does not include `id`.
46
-
47
- ## Dependencies
48
-
49
- - `@nathapp/nestjs-tenant` (workspace)
50
- - `@nathapp/nestjs-prisma` ^3.2.0 (peer) — provides `AbstractPrismaRepository`, `PrismaModule`
51
- - `@nathapp/nestjs-data` ^3.2.0 (transitive) — provides `TRANSACTION_MANAGER`, `ITransactionManager`
52
- - `@prisma/client` ^6.0.0 (peer)
53
-
54
- ## Schema conventions
55
-
56
- All `DateTime` fields in the consumer's `schema.prisma` for models backing this package MUST use `@db.Timestamptz(6)`:
57
-
58
- ```prisma
59
- createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
60
- updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
61
- ```
62
-
63
- This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is NOT correct for this platform.
64
-
65
- When migrating an existing database from bare `DateTime` columns:
66
- ```sql
67
- ALTER TABLE tenants ALTER COLUMN created_at TYPE TIMESTAMPTZ(6) USING created_at AT TIME ZONE 'UTC';
68
- ALTER TABLE tenants ALTER COLUMN updated_at TYPE TIMESTAMPTZ(6) USING updated_at AT TIME ZONE 'UTC';
69
- ```
package/codex.md DELETED
@@ -1,69 +0,0 @@
1
- # Codex Instructions
2
-
3
- This file is auto-generated from `.nax/context.md`.
4
- DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
5
-
6
- ---
7
-
8
- ## Project Metadata
9
-
10
- > Auto-injected by `nax generate`
11
-
12
- **Project:** `@nathapp/nestjs-tenant-prisma`
13
-
14
- **Language:** TypeScript
15
-
16
- **Key dependencies:** @nathapp/nestjs-prisma, typescript
17
-
18
- ---
19
- # CLAUDE.md — @nathapp/nestjs-tenant-prisma
20
-
21
- Prisma adapter for `@nathapp/nestjs-tenant`. Implements `ITenantRepository` using `@prisma/client`.
22
-
23
- ## Status: ✅ Complete
24
-
25
- ## Wiring
26
-
27
- The consumer app registers Prisma with transactions enabled, then this adapter:
28
-
29
- ```typescript
30
- @Module({
31
- imports: [
32
- PrismaModule.forRoot({ client: PrismaClient, transaction: true, isGlobal: true }), // @nathapp/nestjs-prisma
33
- TenantModule.register({ resolver: HeaderTenantResolver }), // @nathapp/nestjs-tenant
34
- TenantPrismaModule.register(), // binds TENANT_REPOSITORY
35
- ],
36
- })
37
- export class AppModule {}
38
- ```
39
-
40
- `PrismaModule.forRoot({ transaction: true })` provides `TRANSACTION_MANAGER`; `PrismaTenantRepository` (extends `AbstractPrismaRepository`) resolves its client per operation from it, so tenant writes participate automatically in any `txManager.run(...)`.
41
-
42
- ## Implementation
43
-
44
- - `PrismaTenantRepository extends AbstractPrismaRepository<Tenant, any, string>` — inherits CRUD + pagination, adds `findBySlug` / `findByDomain` / `exists`.
45
- - `exists` uses `findById` (not `count`) because `AbstractPrismaRepository.count` maps criteria through `toPersistenceUpdate`, which does not include `id`.
46
-
47
- ## Dependencies
48
-
49
- - `@nathapp/nestjs-tenant` (workspace)
50
- - `@nathapp/nestjs-prisma` ^3.2.0 (peer) — provides `AbstractPrismaRepository`, `PrismaModule`
51
- - `@nathapp/nestjs-data` ^3.2.0 (transitive) — provides `TRANSACTION_MANAGER`, `ITransactionManager`
52
- - `@prisma/client` ^6.0.0 (peer)
53
-
54
- ## Schema conventions
55
-
56
- All `DateTime` fields in the consumer's `schema.prisma` for models backing this package MUST use `@db.Timestamptz(6)`:
57
-
58
- ```prisma
59
- createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
60
- updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
61
- ```
62
-
63
- This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is NOT correct for this platform.
64
-
65
- When migrating an existing database from bare `DateTime` columns:
66
- ```sql
67
- ALTER TABLE tenants ALTER COLUMN created_at TYPE TIMESTAMPTZ(6) USING created_at AT TIME ZONE 'UTC';
68
- ALTER TABLE tenants ALTER COLUMN updated_at TYPE TIMESTAMPTZ(6) USING updated_at AT TIME ZONE 'UTC';
69
- ```