@aenode/nest-prisma 0.0.0-stage → 0.0.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
@@ -1,3 +1,25 @@
1
- # Temporary Holding Version
1
+ ![Version](https://img.shields.io/npm/v/@aenode/nest-prisma) ![Downloads](https://img.shields.io/npm/dm/@aenode/nest-prisma) ![Status](https://img.shields.io/github/actions/workflow/status/aenode/aenode/ci.yml) ![Size](https://img.shields.io/bundlephobia/min/@aenode/nest-prisma)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center">
4
+ <img src="https://aenode.github.io/aenode/libs/nest-prisma/assets/favicon.svg" alt="aenode Logo" height="128" width="128" style="border-radius: 32px;"/>
5
+ </p>
6
+
7
+ ## @aenode/nest-prisma
8
+
9
+ Nestjs prisma client module
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ bun add @aenode/nest-prisma
15
+ ```
16
+
17
+ ## Examples
18
+
19
+ ```ts
20
+ const message = 'Hello there';
21
+ ```
22
+
23
+ ---
24
+
25
+ [![CashUp](https://img.shields.io/badge/Cash%20Up-%23EA4AAA.svg?style=for-the-badge&logo=github-sponsors&logoColor=white)](https://cash.app/$puqlib) [![EmainMe](https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=proton&logoColor=white)](mailto:aenode+aenode+aenode-nest-prisma@proton.me)
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" height="48px" width="48px" fill="#5985E1"><path d="M22.93,41.57Q22.5,41.14 22.5,40.5V27.6l-9.1,9.1q-0.44,0.45-1.04,0.45T11.3,36.71t-0.45-1.05T11.3,34.6l9.1-9.1H7.5q-0.64,0-1.07-0.43T6,23.99t0.43-1.07T7.5,22.5H20.45L11.3,13.35q-0.45-0.44-0.45-1.05t0.44-1.05t1.05-0.45t1.06,0.45l9.1,9.1V7.5q0-0.64 0.43-1.07T24.01,6t1.07,0.43T25.5,7.5V20.4l9.15-9.15q0.44-0.45 1.05-0.45t1.05,0.44t0.45,1.05t-0.45,1.06L27.6,22.5H40.5q0.64,0 1.07,0.43T42,24.01t-0.43,1.07T40.5,25.5H27.65l9.1,9.1q0.45,0.44 0.45,1.04T36.76,36.7t-1.05,0.45T34.65,36.7L25.5,27.55V40.5q0,0.64-0.43,1.07T23.99,42t-1.07-0.43Z"/></svg>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import '../dist/main.js';
@@ -0,0 +1,2 @@
1
+ export * from './lib/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './lib/index.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './lib/index.js';\n"],"names":[],"mappings":"AAAA,cAAc,iBAAiB"}
@@ -0,0 +1,5 @@
1
+ export * from './nest-prisma.js';
2
+ export * from './prisma-client.module.js';
3
+ export * from './prisma-client.provider.js';
4
+ export * from './prisma-delegate.provider.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1,7 @@
1
+ // @index(['./**/*.ts', '!./**/*.spec.ts','!./**/index.ts', '!./**/_*.ts','!./**/{main,bootstrap}.ts', '!./**/generated/**'], f => `export * from '${f.path}.js'`)
2
+ export * from './nest-prisma.js';
3
+ export * from './prisma-client.module.js';
4
+ export * from './prisma-client.provider.js';
5
+ export * from './prisma-delegate.provider.js';
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/index.ts"],"sourcesContent":["// @index(['./**/*.ts', '!./**/*.spec.ts','!./**/index.ts', '!./**/_*.ts','!./**/{main,bootstrap}.ts', '!./**/generated/**'], f => `export * from '${f.path}.js'`)\nexport * from './nest-prisma.js';\nexport * from './prisma-client.module.js';\nexport * from './prisma-client.provider.js';\nexport * from './prisma-delegate.provider.js';\n"],"names":[],"mappings":"AAAA,kKAAkK;AAClK,cAAc,mBAAmB;AACjC,cAAc,4BAA4B;AAC1C,cAAc,8BAA8B;AAC5C,cAAc,gCAAgC"}
@@ -0,0 +1,2 @@
1
+ export declare function nestPrisma(): string;
2
+ //# sourceMappingURL=nest-prisma.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nest-prisma.d.ts","sourceRoot":"","sources":["../../src/lib/nest-prisma.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,WAEzB"}
@@ -0,0 +1,5 @@
1
+ export function nestPrisma() {
2
+ return 'nest-prisma';
3
+ }
4
+
5
+ //# sourceMappingURL=nest-prisma.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/nest-prisma.ts"],"sourcesContent":["export function nestPrisma() {\n return 'nest-prisma';\n}\n"],"names":["nestPrisma"],"mappings":"AAAA,OAAO,SAASA;IACd,OAAO;AACT"}
@@ -0,0 +1,7 @@
1
+ import { type DynamicModule, type Type } from '@aenode/nest/common';
2
+ import type { PrismaClient } from '@prisma/client/extension';
3
+ export declare class PrismaClientModule {
4
+ static register(prismaClient: Type<PrismaClient>, scope?: string): DynamicModule;
5
+ static feature(modelNames: string[], scope?: string): DynamicModule;
6
+ }
7
+ //# sourceMappingURL=prisma-client.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-client.module.d.ts","sourceRoot":"","sources":["../../src/lib/prisma-client.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAS7D,qBACa,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CACb,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,EAChC,KAAK,CAAC,EAAE,MAAM,GACb,aAAa;IAShB,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa;CAmBpE"}
@@ -0,0 +1,41 @@
1
+ import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
2
+ import { names } from '@aenode/names';
3
+ import { Module } from '@aenode/nest/common';
4
+ import { getPrismaClientToken, providePrismaClient } from './prisma-client.provider.js';
5
+ import { getPrismaDelegateToken, providePrismaDelegate } from './prisma-delegate.provider.js';
6
+ export class PrismaClientModule {
7
+ static register(prismaClient, scope) {
8
+ return {
9
+ module: PrismaClientModule,
10
+ global: true,
11
+ providers: [
12
+ providePrismaClient(prismaClient, scope)
13
+ ],
14
+ exports: [
15
+ getPrismaClientToken(scope)
16
+ ]
17
+ };
18
+ }
19
+ static feature(modelNames, scope) {
20
+ const providers = modelNames.map((modelName)=>names(modelName).camel).map((modelName)=>{
21
+ return providePrismaDelegate(modelName, scope);
22
+ });
23
+ const exportTokens = modelNames.map((modelName)=>names(modelName).camel).map((modelName)=>{
24
+ return getPrismaDelegateToken(modelName, scope);
25
+ });
26
+ return {
27
+ module: PrismaClientModule,
28
+ providers: [
29
+ ...providers
30
+ ],
31
+ exports: [
32
+ ...exportTokens
33
+ ]
34
+ };
35
+ }
36
+ }
37
+ PrismaClientModule = _ts_decorate([
38
+ Module({})
39
+ ], PrismaClientModule);
40
+
41
+ //# sourceMappingURL=prisma-client.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/prisma-client.module.ts"],"sourcesContent":["import { names } from '@aenode/names';\nimport { Module, type DynamicModule, type Type } from '@aenode/nest/common';\nimport type { PrismaClient } from '@prisma/client/extension';\nimport {\n getPrismaClientToken,\n providePrismaClient,\n} from './prisma-client.provider.js';\nimport {\n getPrismaDelegateToken,\n providePrismaDelegate,\n} from './prisma-delegate.provider.js';\n@Module({})\nexport class PrismaClientModule {\n static register(\n prismaClient: Type<PrismaClient>,\n scope?: string,\n ): DynamicModule {\n return {\n module: PrismaClientModule,\n global: true,\n providers: [providePrismaClient(prismaClient, scope)],\n exports: [getPrismaClientToken(scope)],\n };\n }\n\n static feature(modelNames: string[], scope?: string): DynamicModule {\n const providers = modelNames\n .map((modelName) => names(modelName).camel)\n .map((modelName) => {\n return providePrismaDelegate(modelName, scope);\n });\n\n const exportTokens = modelNames\n .map((modelName) => names(modelName).camel)\n .map((modelName) => {\n return getPrismaDelegateToken(modelName, scope);\n });\n\n return {\n module: PrismaClientModule,\n providers: [...providers],\n exports: [...exportTokens],\n };\n }\n}\n"],"names":["names","Module","getPrismaClientToken","providePrismaClient","getPrismaDelegateToken","providePrismaDelegate","PrismaClientModule","register","prismaClient","scope","module","global","providers","exports","feature","modelNames","map","modelName","camel","exportTokens"],"mappings":";AAAA,SAASA,KAAK,QAAQ,gBAAgB;AACtC,SAASC,MAAM,QAAuC,sBAAsB;AAE5E,SACEC,oBAAoB,EACpBC,mBAAmB,QACd,8BAA8B;AACrC,SACEC,sBAAsB,EACtBC,qBAAqB,QAChB,gCAAgC;AAEvC,OAAO,MAAMC;IACX,OAAOC,SACLC,YAAgC,EAChCC,KAAc,EACC;QACf,OAAO;YACLC,QAAQJ;YACRK,QAAQ;YACRC,WAAW;gBAACT,oBAAoBK,cAAcC;aAAO;YACrDI,SAAS;gBAACX,qBAAqBO;aAAO;QACxC;IACF;IAEA,OAAOK,QAAQC,UAAoB,EAAEN,KAAc,EAAiB;QAClE,MAAMG,YAAYG,WACfC,GAAG,CAAC,CAACC,YAAcjB,MAAMiB,WAAWC,KAAK,EACzCF,GAAG,CAAC,CAACC;YACJ,OAAOZ,sBAAsBY,WAAWR;QAC1C;QAEF,MAAMU,eAAeJ,WAClBC,GAAG,CAAC,CAACC,YAAcjB,MAAMiB,WAAWC,KAAK,EACzCF,GAAG,CAAC,CAACC;YACJ,OAAOb,uBAAuBa,WAAWR;QAC3C;QAEF,OAAO;YACLC,QAAQJ;YACRM,WAAW;mBAAIA;aAAU;YACzBC,SAAS;mBAAIM;aAAa;QAC5B;IACF;AACF"}
@@ -0,0 +1,6 @@
1
+ import { type Provider, type Type } from '@aenode/nest/common';
2
+ import type { PrismaClient } from '@prisma/client/extension';
3
+ export declare function getPrismaClientToken(scope: string | undefined): string;
4
+ export declare function providePrismaClient(client: Type<PrismaClient>, scope: string | undefined): Provider;
5
+ export declare function InjectPrismaClient(scope: string | undefined): ParameterDecorator;
6
+ //# sourceMappingURL=prisma-client.provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-client.provider.d.ts","sourceRoot":"","sources":["../../src/lib/prisma-client.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKtE;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,EAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,QAAQ,CAuDV;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,kBAAkB,CAIpB"}
@@ -0,0 +1,51 @@
1
+ import { Duration, Env } from '@aenode/constants';
2
+ import { Inject } from '@aenode/nest/common';
3
+ import { ConfigService } from '@aenode/nest/config';
4
+ import { PrismaPg } from '@prisma/adapter-pg';
5
+ export function getPrismaClientToken(scope) {
6
+ return [
7
+ scope,
8
+ 'PRISMA_CLIENT_TOKEN'
9
+ ].filter((e)=>e).map((e)=>e?.toUpperCase()).join('_');
10
+ }
11
+ export function providePrismaClient(client, scope) {
12
+ return {
13
+ provide: getPrismaClientToken(scope),
14
+ inject: [
15
+ ConfigService
16
+ ],
17
+ useFactory (config) {
18
+ const SCHEMA = config.getOrThrow(Env.DB.DATABASE_SCHEMA, 'public');
19
+ const URL = config.getOrThrow(Env.DB.DATABASE_URL);
20
+ const CONNECTION_TIMEOUT_MILLIS = config.getOrThrow(Env.DB.PG.CONNECTION_TIMEOUT_MILLIS, Duration.SECONDS_5);
21
+ const IDLE_TIMEOUT_MILLIS = config.getOrThrow(Env.DB.PG.IDLE_TIMEOUT_MILLIS, Duration.SECONDS_10);
22
+ const LOCK_TIMEOUT = config.getOrThrow(Env.DB.PG.LOCK_TIMEOUT, Duration.MINUTES_5);
23
+ const MAX = config.getOrThrow(Env.DB.PG.MAX, 10);
24
+ const MAX_USES = config.getOrThrow(Env.DB.PG.MAX_USES, 7500);
25
+ const QUERY_TIMEOUT = config.getOrThrow(Env.DB.PG.QUERY_TIMEOUT, Duration.SECONDS_5);
26
+ const STATEMENT_TIMEOUT = config.getOrThrow(Env.DB.PG.STATEMENT_TIMEOUT, Duration.SECONDS_5);
27
+ const adapter = new PrismaPg({
28
+ connectionString: URL,
29
+ connectionTimeoutMillis: CONNECTION_TIMEOUT_MILLIS,
30
+ idleTimeoutMillis: IDLE_TIMEOUT_MILLIS,
31
+ lock_timeout: LOCK_TIMEOUT,
32
+ max: MAX,
33
+ maxUses: MAX_USES,
34
+ query_timeout: QUERY_TIMEOUT,
35
+ statement_timeout: STATEMENT_TIMEOUT
36
+ }, {
37
+ schema: SCHEMA
38
+ });
39
+ return new client({
40
+ adapter
41
+ });
42
+ }
43
+ };
44
+ }
45
+ export function InjectPrismaClient(scope) {
46
+ return (...args)=>{
47
+ Inject(getPrismaClientToken(scope))(...args);
48
+ };
49
+ }
50
+
51
+ //# sourceMappingURL=prisma-client.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/prisma-client.provider.ts"],"sourcesContent":["import { Duration, Env } from '@aenode/constants';\nimport { Inject, type Provider, type Type } from '@aenode/nest/common';\nimport { ConfigService } from '@aenode/nest/config';\nimport { PrismaPg } from '@prisma/adapter-pg';\nimport type { PrismaClient } from '@prisma/client/extension';\n\nexport function getPrismaClientToken(scope: string | undefined): string {\n return [scope, 'PRISMA_CLIENT_TOKEN']\n .filter((e) => e)\n .map((e) => e?.toUpperCase())\n .join('_');\n}\n\nexport function providePrismaClient(\n client: Type<PrismaClient>,\n scope: string | undefined,\n): Provider {\n return {\n provide: getPrismaClientToken(scope),\n inject: [ConfigService],\n useFactory(config: ConfigService) {\n const SCHEMA = config.getOrThrow(Env.DB.DATABASE_SCHEMA, 'public');\n\n const URL = config.getOrThrow(Env.DB.DATABASE_URL);\n\n const CONNECTION_TIMEOUT_MILLIS = config.getOrThrow(\n Env.DB.PG.CONNECTION_TIMEOUT_MILLIS,\n Duration.SECONDS_5,\n );\n\n const IDLE_TIMEOUT_MILLIS = config.getOrThrow(\n Env.DB.PG.IDLE_TIMEOUT_MILLIS,\n Duration.SECONDS_10,\n );\n\n const LOCK_TIMEOUT = config.getOrThrow(\n Env.DB.PG.LOCK_TIMEOUT,\n Duration.MINUTES_5,\n );\n\n const MAX = config.getOrThrow(Env.DB.PG.MAX, 10);\n\n const MAX_USES = config.getOrThrow(Env.DB.PG.MAX_USES, 7500);\n\n const QUERY_TIMEOUT = config.getOrThrow(\n Env.DB.PG.QUERY_TIMEOUT,\n Duration.SECONDS_5,\n );\n\n const STATEMENT_TIMEOUT = config.getOrThrow(\n Env.DB.PG.STATEMENT_TIMEOUT,\n Duration.SECONDS_5,\n );\n\n const adapter = new PrismaPg(\n {\n connectionString: URL,\n connectionTimeoutMillis: CONNECTION_TIMEOUT_MILLIS,\n idleTimeoutMillis: IDLE_TIMEOUT_MILLIS,\n lock_timeout: LOCK_TIMEOUT,\n max: MAX,\n maxUses: MAX_USES,\n query_timeout: QUERY_TIMEOUT,\n statement_timeout: STATEMENT_TIMEOUT,\n },\n\n { schema: SCHEMA },\n );\n return new client({ adapter });\n },\n };\n}\n\nexport function InjectPrismaClient(\n scope: string | undefined,\n): ParameterDecorator {\n return (...args) => {\n Inject(getPrismaClientToken(scope))(...args);\n };\n}\n"],"names":["Duration","Env","Inject","ConfigService","PrismaPg","getPrismaClientToken","scope","filter","e","map","toUpperCase","join","providePrismaClient","client","provide","inject","useFactory","config","SCHEMA","getOrThrow","DB","DATABASE_SCHEMA","URL","DATABASE_URL","CONNECTION_TIMEOUT_MILLIS","PG","SECONDS_5","IDLE_TIMEOUT_MILLIS","SECONDS_10","LOCK_TIMEOUT","MINUTES_5","MAX","MAX_USES","QUERY_TIMEOUT","STATEMENT_TIMEOUT","adapter","connectionString","connectionTimeoutMillis","idleTimeoutMillis","lock_timeout","max","maxUses","query_timeout","statement_timeout","schema","InjectPrismaClient","args"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,GAAG,QAAQ,oBAAoB;AAClD,SAASC,MAAM,QAAkC,sBAAsB;AACvE,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,QAAQ,QAAQ,qBAAqB;AAG9C,OAAO,SAASC,qBAAqBC,KAAyB;IAC5D,OAAO;QAACA;QAAO;KAAsB,CAClCC,MAAM,CAAC,CAACC,IAAMA,GACdC,GAAG,CAAC,CAACD,IAAMA,GAAGE,eACdC,IAAI,CAAC;AACV;AAEA,OAAO,SAASC,oBACdC,MAA0B,EAC1BP,KAAyB;IAEzB,OAAO;QACLQ,SAAST,qBAAqBC;QAC9BS,QAAQ;YAACZ;SAAc;QACvBa,YAAWC,MAAqB;YAC9B,MAAMC,SAASD,OAAOE,UAAU,CAAClB,IAAImB,EAAE,CAACC,eAAe,EAAE;YAEzD,MAAMC,MAAML,OAAOE,UAAU,CAAClB,IAAImB,EAAE,CAACG,YAAY;YAEjD,MAAMC,4BAA4BP,OAAOE,UAAU,CACjDlB,IAAImB,EAAE,CAACK,EAAE,CAACD,yBAAyB,EACnCxB,SAAS0B,SAAS;YAGpB,MAAMC,sBAAsBV,OAAOE,UAAU,CAC3ClB,IAAImB,EAAE,CAACK,EAAE,CAACE,mBAAmB,EAC7B3B,SAAS4B,UAAU;YAGrB,MAAMC,eAAeZ,OAAOE,UAAU,CACpClB,IAAImB,EAAE,CAACK,EAAE,CAACI,YAAY,EACtB7B,SAAS8B,SAAS;YAGpB,MAAMC,MAAMd,OAAOE,UAAU,CAAClB,IAAImB,EAAE,CAACK,EAAE,CAACM,GAAG,EAAE;YAE7C,MAAMC,WAAWf,OAAOE,UAAU,CAAClB,IAAImB,EAAE,CAACK,EAAE,CAACO,QAAQ,EAAE;YAEvD,MAAMC,gBAAgBhB,OAAOE,UAAU,CACrClB,IAAImB,EAAE,CAACK,EAAE,CAACQ,aAAa,EACvBjC,SAAS0B,SAAS;YAGpB,MAAMQ,oBAAoBjB,OAAOE,UAAU,CACzClB,IAAImB,EAAE,CAACK,EAAE,CAACS,iBAAiB,EAC3BlC,SAAS0B,SAAS;YAGpB,MAAMS,UAAU,IAAI/B,SAClB;gBACEgC,kBAAkBd;gBAClBe,yBAAyBb;gBACzBc,mBAAmBX;gBACnBY,cAAcV;gBACdW,KAAKT;gBACLU,SAAST;gBACTU,eAAeT;gBACfU,mBAAmBT;YACrB,GAEA;gBAAEU,QAAQ1B;YAAO;YAEnB,OAAO,IAAIL,OAAO;gBAAEsB;YAAQ;QAC9B;IACF;AACF;AAEA,OAAO,SAASU,mBACdvC,KAAyB;IAEzB,OAAO,CAAC,GAAGwC;QACT5C,OAAOG,qBAAqBC,WAAWwC;IACzC;AACF"}
@@ -0,0 +1,5 @@
1
+ import { type Provider } from '@aenode/nest/common';
2
+ export declare function getPrismaDelegateToken(modelName: string, scope: string | undefined): string;
3
+ export declare function providePrismaDelegate(modelName: string, scope: string | undefined): Provider;
4
+ export declare function InjectPrismaDelegate(modelName: string, scope?: string): ParameterDecorator;
5
+ //# sourceMappingURL=prisma-delegate.provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-delegate.provider.d.ts","sourceRoot":"","sources":["../../src/lib/prisma-delegate.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAI5D,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,CAKR;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,QAAQ,CAQV;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,GACb,kBAAkB,CAIpB"}
@@ -0,0 +1,27 @@
1
+ import { Inject } from '@aenode/nest/common';
2
+ import { getPrismaClientToken } from './prisma-client.provider.js';
3
+ export function getPrismaDelegateToken(modelName, scope) {
4
+ return [
5
+ scope,
6
+ modelName,
7
+ 'PRISMA_DELEGATE_TOKEN'
8
+ ].filter((e)=>e).map((e)=>e?.toUpperCase()).join('_');
9
+ }
10
+ export function providePrismaDelegate(modelName, scope) {
11
+ return {
12
+ provide: getPrismaDelegateToken(modelName, scope),
13
+ inject: [
14
+ getPrismaClientToken(scope)
15
+ ],
16
+ useFactory (client) {
17
+ return client[modelName];
18
+ }
19
+ };
20
+ }
21
+ export function InjectPrismaDelegate(modelName, scope) {
22
+ return (...args)=>{
23
+ Inject(getPrismaDelegateToken(modelName, scope))(...args);
24
+ };
25
+ }
26
+
27
+ //# sourceMappingURL=prisma-delegate.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/prisma-delegate.provider.ts"],"sourcesContent":["import { Inject, type Provider } from '@aenode/nest/common';\nimport type { PrismaClient } from '@prisma/client/extension';\nimport { getPrismaClientToken } from './prisma-client.provider.js';\n\nexport function getPrismaDelegateToken(\n modelName: string,\n scope: string | undefined,\n): string {\n return [scope, modelName, 'PRISMA_DELEGATE_TOKEN']\n .filter((e) => e)\n .map((e) => e?.toUpperCase())\n .join('_');\n}\n\nexport function providePrismaDelegate(\n modelName: string,\n scope: string | undefined,\n): Provider {\n return {\n provide: getPrismaDelegateToken(modelName, scope),\n inject: [getPrismaClientToken(scope)],\n useFactory(client: PrismaClient) {\n return client[modelName];\n },\n };\n}\n\nexport function InjectPrismaDelegate(\n modelName: string,\n scope?: string,\n): ParameterDecorator {\n return (...args) => {\n Inject(getPrismaDelegateToken(modelName, scope))(...args);\n };\n}\n"],"names":["Inject","getPrismaClientToken","getPrismaDelegateToken","modelName","scope","filter","e","map","toUpperCase","join","providePrismaDelegate","provide","inject","useFactory","client","InjectPrismaDelegate","args"],"mappings":"AAAA,SAASA,MAAM,QAAuB,sBAAsB;AAE5D,SAASC,oBAAoB,QAAQ,8BAA8B;AAEnE,OAAO,SAASC,uBACdC,SAAiB,EACjBC,KAAyB;IAEzB,OAAO;QAACA;QAAOD;QAAW;KAAwB,CAC/CE,MAAM,CAAC,CAACC,IAAMA,GACdC,GAAG,CAAC,CAACD,IAAMA,GAAGE,eACdC,IAAI,CAAC;AACV;AAEA,OAAO,SAASC,sBACdP,SAAiB,EACjBC,KAAyB;IAEzB,OAAO;QACLO,SAAST,uBAAuBC,WAAWC;QAC3CQ,QAAQ;YAACX,qBAAqBG;SAAO;QACrCS,YAAWC,MAAoB;YAC7B,OAAOA,MAAM,CAACX,UAAU;QAC1B;IACF;AACF;AAEA,OAAO,SAASY,qBACdZ,SAAiB,EACjBC,KAAc;IAEd,OAAO,CAAC,GAAGY;QACThB,OAAOE,uBAAuBC,WAAWC,WAAWY;IACtD;AACF"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
package/dist/main.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ console.log(`Hello from @aenode/nest-prisma`);
3
+
4
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/main.ts"],"sourcesContent":["#!/usr/bin/env node\n\nconsole.log(`Hello from @aenode/nest-prisma`);\n"],"names":["console","log"],"mappings":";AAEAA,QAAQC,GAAG,CAAC,CAAC,8BAA8B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@aenode/nest-prisma",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Nestjs prisma client module",
5
+ "author": {
6
+ "name": "Ahmet Emrebas",
7
+ "email": "aenode+aenode+aenode-nest-prisma@proton.me",
8
+ "url": "https://aenode.github.io/#profile"
9
+ },
10
+ "bin": {
11
+ "aenode-nest-prisma": "./bin/nest-prisma.mjs"
12
+ },
13
+ "funding": "https://cash.app/$puqlib",
14
+ "homepage": "https://aenode.github.io/aenode/libs/nest-prisma",
15
+ "repository": {
16
+ "directory": "libs/nest-prisma",
17
+ "type": "github",
18
+ "url": "https://github.com/aenode/aenode/tree/main/libs/nest-prisma"
19
+ },
20
+ "icon": "https://aenode.github.io/aenode/libs/nest-prisma/assets/favicon.svg",
21
+ "keywords": [
22
+ "lib"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "tag": "latest"
27
+ },
28
+ "type": "module",
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ "./package.json": "./package.json",
34
+ ".": {
35
+ "bun": "./src/index.ts",
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js",
38
+ "default": "./dist/index.js"
39
+ }
40
+ },
41
+ "files": [
42
+ "assets",
43
+ "bin",
44
+ "dist",
45
+ "generators.json",
46
+ "!**/*.tsbuildinfo"
47
+ ],
48
+ "nx": {
49
+ "sourceRoot": "libs/nest-prisma/src",
50
+ "projectType": "library",
51
+ "tags": [
52
+ "lib:nest-prisma"
53
+ ],
54
+ "targets": {
55
+ "build": {},
56
+ "doc": {}
57
+ }
58
+ },
59
+ "dependencies": {
60
+ "@aenode/constants": "workspace:*",
61
+ "@aenode/names": "workspace:*",
62
+ "@aenode/nest": "workspace:*",
63
+ "@prisma/adapter-pg": "^7.10.1",
64
+ "@prisma/client": "7.8.0",
65
+ "@swc/helpers": "~0.5.18"
66
+ }
67
+ }