@nathapp/nestjs-tenant-prisma 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.
- package/AGENTS.md +71 -0
- package/CLAUDE.md +69 -0
- package/GEMINI.md +69 -0
- package/README.md +111 -0
- package/codex.md +69 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/prisma-tenant.repository.d.ts +32 -0
- package/dist/prisma-tenant.repository.js +87 -0
- package/dist/prisma-tenant.repository.js.map +1 -0
- package/dist/tenant-prisma.module.d.ts +7 -0
- package/dist/tenant-prisma.module.js +32 -0
- package/dist/tenant-prisma.module.js.map +1 -0
- package/package.json +41 -0
- package/prisma/tenant.prisma +21 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# @nathapp/nestjs-tenant-prisma
|
|
2
|
+
|
|
3
|
+
Prisma adapter for `@nathapp/nestjs-tenant`. Binds the core package's repository
|
|
4
|
+
tokens to `AbstractPrismaRepository`-based implementations.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```shell
|
|
9
|
+
npm i @nathapp/nestjs-tenant-prisma
|
|
10
|
+
npm i -D prisma && npx prisma init
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Schema
|
|
14
|
+
|
|
15
|
+
Append the `Tenant` model from the packaged fragment
|
|
16
|
+
`node_modules/@nathapp/nestjs-tenant-prisma/prisma/tenant.prisma` to your app's
|
|
17
|
+
`schema.prisma`. The fragment carries no `datasource` or `generator` block — it
|
|
18
|
+
is models only. Every `DateTime` in it uses `@db.Timestamptz(6)` (PostgreSQL
|
|
19
|
+
`timestamptz`); bare `DateTime` is not supported.
|
|
20
|
+
|
|
21
|
+
**PostgreSQL and MySQL.** The fragment is authored for PostgreSQL 16 and also
|
|
22
|
+
supports MySQL 8.0. For MySQL, assemble it with `@db.Timestamptz(6)` rewritten
|
|
23
|
+
to `@db.DateTime(6)` (the only change; see the `@nathapp/nestjs-iam-prisma`
|
|
24
|
+
README, "Schema assembly and database support") and keep the MySQL server and
|
|
25
|
+
sessions on UTC (`time_zone = '+00:00'`), because `DATETIME(6)` stores no
|
|
26
|
+
timezone.
|
|
27
|
+
|
|
28
|
+
## Register
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { Module } from '@nestjs/common';
|
|
32
|
+
import { PrismaClient } from '@prisma/client';
|
|
33
|
+
import { PrismaModule } from '@nathapp/nestjs-prisma';
|
|
34
|
+
import { TenantPrismaModule } from '@nathapp/nestjs-tenant-prisma';
|
|
35
|
+
|
|
36
|
+
@Module({
|
|
37
|
+
imports: [
|
|
38
|
+
PrismaModule.forRoot({ client: PrismaClient, transaction: true }),
|
|
39
|
+
TenantPrismaModule.register(),
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
export class AppModule {}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`register()` takes an optional options object:
|
|
46
|
+
|
|
47
|
+
| Option | Type | Default | Meaning |
|
|
48
|
+
|---|---|---|---|
|
|
49
|
+
| `global` | `boolean` | `true` | Register as a global module so the repository tokens resolve anywhere. |
|
|
50
|
+
|
|
51
|
+
`register()` is the only import form for this adapter. There is no `registerAsync`.
|
|
52
|
+
|
|
53
|
+
### If you already wrap this adapter in `@Global()`
|
|
54
|
+
|
|
55
|
+
Pass `global: false`. Otherwise the adapter's own global exports are injected
|
|
56
|
+
**in addition to** your override, and last-registration-wins silently decides
|
|
57
|
+
which implementation is used:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { Global, Module } from '@nestjs/common';
|
|
61
|
+
import { TENANT_REPOSITORY } from '@nathapp/nestjs-tenant';
|
|
62
|
+
import { TenantPrismaModule } from '@nathapp/nestjs-tenant-prisma';
|
|
63
|
+
import { CachedTenantRepository } from './cached-tenant.repository';
|
|
64
|
+
|
|
65
|
+
@Global()
|
|
66
|
+
@Module({
|
|
67
|
+
imports: [TenantPrismaModule.register({ global: false })],
|
|
68
|
+
providers: [{ provide: TENANT_REPOSITORY, useClass: CachedTenantRepository }],
|
|
69
|
+
exports: [TENANT_REPOSITORY],
|
|
70
|
+
})
|
|
71
|
+
export class PrismaOverridesModule {}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`global: false` only helps if the adapter is registered once. A second, global
|
|
75
|
+
`register()` elsewhere in the app keeps its global exports, and `global: false`
|
|
76
|
+
here does not remove them — so the collision this section exists to prevent is
|
|
77
|
+
still there. Register the adapter in exactly one place.
|
|
78
|
+
|
|
79
|
+
The `global` option carries no documentation in the published type definitions
|
|
80
|
+
(`removeComments: true` strips the JSDoc from the emitted `.d.ts`), so this README
|
|
81
|
+
is where it is described. The options object is typed as `PrismaAdapterModuleOptions`,
|
|
82
|
+
which is exported from this package if you need to name the type.
|
|
83
|
+
|
|
84
|
+
## Transactions
|
|
85
|
+
|
|
86
|
+
Multi-write flows need `PrismaModule.forRoot({ client: PrismaClient, transaction: true })`.
|
|
87
|
+
Every repository resolves its client per operation from the `TRANSACTION_MANAGER`
|
|
88
|
+
token, and the two `PrismaModule` registration paths fail differently when
|
|
89
|
+
`transaction` is omitted:
|
|
90
|
+
|
|
91
|
+
- `PrismaModule.forRoot()` binds `TRANSACTION_MANAGER` only when `transaction: true`
|
|
92
|
+
is set. Without it nothing is bound, the repositories cannot resolve their
|
|
93
|
+
dependency, and Nest fails at boot.
|
|
94
|
+
- `PrismaModule.forRootAsync()` always binds the token, but with a manager whose
|
|
95
|
+
`run()` and `getClient()` throw and whose `isInTransaction()` returns `false`, so
|
|
96
|
+
the app boots and fails on first use instead.
|
|
97
|
+
|
|
98
|
+
Neither path is a silent passthrough: a real transaction manager either joins the
|
|
99
|
+
transaction already in scope or opens a Prisma interactive transaction.
|
|
100
|
+
|
|
101
|
+
Both of those are `PrismaModule` from `@nathapp/nestjs-prisma`. These adapters
|
|
102
|
+
expose only the synchronous `register()`; they have no `registerAsync`.
|
|
103
|
+
|
|
104
|
+
## Tokens bound
|
|
105
|
+
|
|
106
|
+
| Token | Implementation |
|
|
107
|
+
|---|---|
|
|
108
|
+
| `TENANT_REPOSITORY` | `PrismaTenantRepository` |
|
|
109
|
+
|
|
110
|
+
`PrismaTenantRepository` adds `findBySlug`, `findByDomain` and `exists` on top of
|
|
111
|
+
the base class.
|
package/codex.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
```
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TenantPrismaModule = exports.PrismaTenantRepository = void 0;
|
|
18
|
+
__exportStar(require("@nathapp/nestjs-tenant"), exports);
|
|
19
|
+
var prisma_tenant_repository_1 = require("./prisma-tenant.repository");
|
|
20
|
+
Object.defineProperty(exports, "PrismaTenantRepository", { enumerable: true, get: function () { return prisma_tenant_repository_1.PrismaTenantRepository; } });
|
|
21
|
+
var tenant_prisma_module_1 = require("./tenant-prisma.module");
|
|
22
|
+
Object.defineProperty(exports, "TenantPrismaModule", { enumerable: true, get: function () { return tenant_prisma_module_1.TenantPrismaModule; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,yDAAuC;AAGvC,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA;AAC/B,+DAA6F;AAApF,0HAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AbstractPrismaRepository } from '@nathapp/nestjs-prisma';
|
|
2
|
+
import { ITransactionManager } from '@nathapp/nestjs-data';
|
|
3
|
+
import type { PrismaClientLike, PrismaModelDelegate } from '@nathapp/nestjs-prisma';
|
|
4
|
+
import { ITenantRepository, Tenant, TenantStatus } from '@nathapp/nestjs-tenant';
|
|
5
|
+
interface TenantRow {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
domain: string | null;
|
|
10
|
+
status: string;
|
|
11
|
+
settings: unknown;
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
updatedAt: Date;
|
|
14
|
+
}
|
|
15
|
+
export declare class PrismaTenantRepository extends AbstractPrismaRepository<Tenant, TenantRow, string> implements ITenantRepository {
|
|
16
|
+
constructor(tx: ITransactionManager);
|
|
17
|
+
protected modelDelegate(client: PrismaClientLike): PrismaModelDelegate<TenantRow, string>;
|
|
18
|
+
protected toDomain(entity: TenantRow): Tenant;
|
|
19
|
+
protected toPersistenceCreate(d: Tenant): {
|
|
20
|
+
status: TenantStatus;
|
|
21
|
+
settings: Record<string, unknown>;
|
|
22
|
+
domain?: string | undefined;
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
slug: string;
|
|
26
|
+
};
|
|
27
|
+
protected toPersistenceUpdate(p: Partial<Tenant>): Record<string, unknown>;
|
|
28
|
+
findBySlug(slug: string): Promise<Tenant | null>;
|
|
29
|
+
findByDomain(domain: string): Promise<Tenant | null>;
|
|
30
|
+
exists(id: string): Promise<boolean>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PrismaTenantRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const nestjs_prisma_1 = require("@nathapp/nestjs-prisma");
|
|
18
|
+
const nestjs_data_1 = require("@nathapp/nestjs-data");
|
|
19
|
+
let PrismaTenantRepository = class PrismaTenantRepository extends nestjs_prisma_1.AbstractPrismaRepository {
|
|
20
|
+
constructor(tx) {
|
|
21
|
+
super(tx);
|
|
22
|
+
}
|
|
23
|
+
modelDelegate(client) {
|
|
24
|
+
return client.tenant;
|
|
25
|
+
}
|
|
26
|
+
toDomain(entity) {
|
|
27
|
+
var _a;
|
|
28
|
+
return {
|
|
29
|
+
id: entity.id,
|
|
30
|
+
name: entity.name,
|
|
31
|
+
slug: entity.slug,
|
|
32
|
+
domain: (_a = entity.domain) !== null && _a !== void 0 ? _a : undefined,
|
|
33
|
+
status: entity.status,
|
|
34
|
+
settings: readSettings(entity.settings),
|
|
35
|
+
createdAt: entity.createdAt,
|
|
36
|
+
updatedAt: entity.updatedAt,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
toPersistenceCreate(d) {
|
|
40
|
+
var _a;
|
|
41
|
+
return {
|
|
42
|
+
id: d.id,
|
|
43
|
+
name: d.name,
|
|
44
|
+
slug: d.slug,
|
|
45
|
+
...(d.domain !== undefined && { domain: d.domain }),
|
|
46
|
+
status: d.status,
|
|
47
|
+
settings: (_a = d.settings) !== null && _a !== void 0 ? _a : {},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
toPersistenceUpdate(p) {
|
|
51
|
+
const out = {};
|
|
52
|
+
if (p.name !== undefined)
|
|
53
|
+
out.name = p.name;
|
|
54
|
+
if (p.slug !== undefined)
|
|
55
|
+
out.slug = p.slug;
|
|
56
|
+
if (p.domain !== undefined)
|
|
57
|
+
out.domain = p.domain;
|
|
58
|
+
if (p.status !== undefined)
|
|
59
|
+
out.status = p.status;
|
|
60
|
+
if (p.settings !== undefined)
|
|
61
|
+
out.settings = p.settings;
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
async findBySlug(slug) {
|
|
65
|
+
const entity = await this.model.findFirst({ where: { slug } });
|
|
66
|
+
return entity ? this.toDomain(entity) : null;
|
|
67
|
+
}
|
|
68
|
+
async findByDomain(domain) {
|
|
69
|
+
const entity = await this.model.findFirst({ where: { domain } });
|
|
70
|
+
return entity ? this.toDomain(entity) : null;
|
|
71
|
+
}
|
|
72
|
+
async exists(id) {
|
|
73
|
+
return (await this.findById(id)) !== null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.PrismaTenantRepository = PrismaTenantRepository;
|
|
77
|
+
exports.PrismaTenantRepository = PrismaTenantRepository = __decorate([
|
|
78
|
+
(0, common_1.Injectable)(),
|
|
79
|
+
__param(0, (0, common_1.Inject)(nestjs_data_1.TRANSACTION_MANAGER)),
|
|
80
|
+
__metadata("design:paramtypes", [Object])
|
|
81
|
+
], PrismaTenantRepository);
|
|
82
|
+
function readSettings(value) {
|
|
83
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
84
|
+
? value
|
|
85
|
+
: undefined;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=prisma-tenant.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-tenant.repository.js","sourceRoot":"","sources":["../lib/prisma-tenant.repository.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var TenantPrismaModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TenantPrismaModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const nestjs_tenant_1 = require("@nathapp/nestjs-tenant");
|
|
13
|
+
const prisma_tenant_repository_1 = require("./prisma-tenant.repository");
|
|
14
|
+
let TenantPrismaModule = TenantPrismaModule_1 = class TenantPrismaModule {
|
|
15
|
+
static register(options) {
|
|
16
|
+
var _a;
|
|
17
|
+
return {
|
|
18
|
+
module: TenantPrismaModule_1,
|
|
19
|
+
global: (_a = options === null || options === void 0 ? void 0 : options.global) !== null && _a !== void 0 ? _a : true,
|
|
20
|
+
providers: [
|
|
21
|
+
prisma_tenant_repository_1.PrismaTenantRepository,
|
|
22
|
+
{ provide: nestjs_tenant_1.TENANT_REPOSITORY, useExisting: prisma_tenant_repository_1.PrismaTenantRepository },
|
|
23
|
+
],
|
|
24
|
+
exports: [nestjs_tenant_1.TENANT_REPOSITORY],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.TenantPrismaModule = TenantPrismaModule;
|
|
29
|
+
exports.TenantPrismaModule = TenantPrismaModule = TenantPrismaModule_1 = __decorate([
|
|
30
|
+
(0, common_1.Module)({})
|
|
31
|
+
], TenantPrismaModule);
|
|
32
|
+
//# sourceMappingURL=tenant-prisma.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-prisma.module.js","sourceRoot":"","sources":["../lib/tenant-prisma.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,0DAA2D;AAC3D,yEAAoE;AAuB7D,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CAAC,OAAoC;;QAClD,OAAO;YACL,MAAM,EAAE,oBAAkB;YAC1B,MAAM,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,IAAI;YAC/B,SAAS,EAAE;gBACT,iDAAsB;gBACtB,EAAE,OAAO,EAAE,iCAAiB,EAAE,WAAW,EAAE,iDAAsB,EAAE;aACpE;YACD,OAAO,EAAE,CAAC,iCAAiB,CAAC;SAC7B,CAAC;IACJ,CAAC;CACF,CAAA;AAZY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,kBAAkB,CAY9B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nathapp/nestjs-tenant-prisma",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Prisma adapter for @nathapp/nestjs-tenant",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
7
|
+
"clean": "rimraf dist/ .turbo/",
|
|
8
|
+
"lint": "eslint -c .eslintrc.js --ext .ts .",
|
|
9
|
+
"lint:fix": "eslint -c .eslintrc.js --ext .ts . --fix",
|
|
10
|
+
"test": "jest --config ./test/jest-test.json --forceExit --no-colors --silent",
|
|
11
|
+
"test:json": "jest --config ./test/jest-test.json --json --no-colors --silent",
|
|
12
|
+
"test:verbose": "jest --config ./test/jest-test.json",
|
|
13
|
+
"test:cov": "jest --config ./test/jest-test.json --coverage",
|
|
14
|
+
"type-check": "tsc --noEmit -p tsconfig.json"
|
|
15
|
+
},
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
20
|
+
},
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"directories": {
|
|
24
|
+
"lib": "lib"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@nathapp/nestjs-tenant": "1.0.0",
|
|
28
|
+
"@nathapp/nestjs-data": "^3.3.0 || ^4.0.2"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@nathapp/nestjs-prisma": "^4.0.2",
|
|
32
|
+
"eslint": "^8.57.0",
|
|
33
|
+
"typescript": "^5"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@nestjs/common": "^11.0.0 || ^12.1.0",
|
|
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"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// === @nathapp/nestjs-tenant schema fragment ===
|
|
2
|
+
// Append these models to your application's schema.prisma.
|
|
3
|
+
//
|
|
4
|
+
// TZ NOTE: All DateTime fields use @db.Timestamptz(6) (timestamptz in PostgreSQL).
|
|
5
|
+
// When migrating an existing database, use:
|
|
6
|
+
// ALTER TABLE t ALTER COLUMN col TYPE TIMESTAMPTZ(6) USING col AT TIME ZONE 'UTC';
|
|
7
|
+
// The USING clause treats existing values as UTC — safe if your DB was UTC-configured.
|
|
8
|
+
// Verify your DB timezone (SHOW timezone;) before running migrations on production data.
|
|
9
|
+
|
|
10
|
+
model Tenant {
|
|
11
|
+
id String @id @default(uuid())
|
|
12
|
+
name String
|
|
13
|
+
slug String @unique
|
|
14
|
+
domain String? @unique
|
|
15
|
+
status String
|
|
16
|
+
settings Json @default("{}")
|
|
17
|
+
createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
|
|
18
|
+
updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
|
|
19
|
+
|
|
20
|
+
@@map("tenants")
|
|
21
|
+
}
|