@prisma-next/mongo 0.4.0-dev.8 → 0.4.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/dist/config.mjs +3 -12
- package/dist/config.mjs.map +1 -1
- package/dist/runtime.d.mts +3 -3
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +4 -4
- package/dist/runtime.mjs.map +1 -1
- package/package.json +14 -14
- package/src/config/define-config.ts +4 -18
- package/src/runtime/mongo.ts +6 -6
package/dist/config.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { pathToFileURL } from "node:url";
|
|
2
1
|
import mongoAdapter from "@prisma-next/adapter-mongo/control";
|
|
3
2
|
import { defineConfig as defineConfig$1 } from "@prisma-next/config/config-types";
|
|
4
3
|
import mongoDriver from "@prisma-next/driver-mongo/control";
|
|
5
4
|
import { mongoFamilyDescriptor, mongoTargetDescriptor } from "@prisma-next/family-mongo/control";
|
|
6
5
|
import { mongoContract } from "@prisma-next/mongo-contract-psl/provider";
|
|
7
|
-
import {
|
|
6
|
+
import { typescriptContractFromPath } from "@prisma-next/mongo-contract-ts/config-types";
|
|
7
|
+
import { extname } from "pathe";
|
|
8
8
|
|
|
9
9
|
//#region src/config/define-config.ts
|
|
10
10
|
function deriveOutputPath(contractPath) {
|
|
@@ -14,21 +14,12 @@ function deriveOutputPath(contractPath) {
|
|
|
14
14
|
}
|
|
15
15
|
function defineConfig(options) {
|
|
16
16
|
const output = deriveOutputPath(options.contract);
|
|
17
|
-
const ext = extname(options.contract);
|
|
18
|
-
const absoluteContractPath = isAbsolute(options.contract) ? options.contract : resolve(process.cwd(), options.contract);
|
|
19
17
|
return defineConfig$1({
|
|
20
18
|
family: mongoFamilyDescriptor,
|
|
21
19
|
target: mongoTargetDescriptor,
|
|
22
20
|
adapter: mongoAdapter,
|
|
23
21
|
driver: mongoDriver,
|
|
24
|
-
contract:
|
|
25
|
-
source: async (context) => {
|
|
26
|
-
const { typescriptContract } = await import("@prisma-next/mongo-contract-ts/config-types");
|
|
27
|
-
const mod = await import(pathToFileURL(absoluteContractPath).href);
|
|
28
|
-
return typescriptContract(mod.default ?? mod.contract, output).source(context);
|
|
29
|
-
},
|
|
30
|
-
output
|
|
31
|
-
} : mongoContract(options.contract, { output }),
|
|
22
|
+
contract: extname(options.contract) === ".ts" ? typescriptContractFromPath(options.contract, output) : mongoContract(options.contract, { output }),
|
|
32
23
|
...options.db !== void 0 ? { db: options.db } : {}
|
|
33
24
|
});
|
|
34
25
|
}
|
package/dist/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":["coreDefineConfig"],"sources":["../src/config/define-config.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"config.mjs","names":["coreDefineConfig"],"sources":["../src/config/define-config.ts"],"sourcesContent":["import mongoAdapter from '@prisma-next/adapter-mongo/control';\nimport type { PrismaNextConfig } from '@prisma-next/config/config-types';\nimport { defineConfig as coreDefineConfig } from '@prisma-next/config/config-types';\nimport mongoDriver from '@prisma-next/driver-mongo/control';\nimport { mongoFamilyDescriptor, mongoTargetDescriptor } from '@prisma-next/family-mongo/control';\nimport { mongoContract } from '@prisma-next/mongo-contract-psl/provider';\nimport { typescriptContractFromPath } from '@prisma-next/mongo-contract-ts/config-types';\nimport { extname } from 'pathe';\n\nexport interface MongoConfigOptions {\n readonly contract: string;\n readonly db?: {\n readonly connection?: string;\n };\n}\n\nfunction deriveOutputPath(contractPath: string): string {\n const ext = extname(contractPath);\n if (ext.length === 0) {\n return `${contractPath}.json`;\n }\n return `${contractPath.slice(0, -ext.length)}.json`;\n}\n\nexport function defineConfig(options: MongoConfigOptions): PrismaNextConfig<'mongo', 'mongo'> {\n const output = deriveOutputPath(options.contract);\n const ext = extname(options.contract);\n\n const contractConfig =\n ext === '.ts'\n ? typescriptContractFromPath(options.contract, output)\n : mongoContract(options.contract, { output });\n\n return coreDefineConfig({\n family: mongoFamilyDescriptor,\n target: mongoTargetDescriptor,\n adapter: mongoAdapter,\n driver: mongoDriver,\n contract: contractConfig,\n ...(options.db !== undefined ? { db: options.db } : {}),\n });\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAS,iBAAiB,cAA8B;CACtD,MAAM,MAAM,QAAQ,aAAa;AACjC,KAAI,IAAI,WAAW,EACjB,QAAO,GAAG,aAAa;AAEzB,QAAO,GAAG,aAAa,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC;;AAG/C,SAAgB,aAAa,SAAiE;CAC5F,MAAM,SAAS,iBAAiB,QAAQ,SAAS;AAQjD,QAAOA,eAAiB;EACtB,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,UAZU,QAAQ,QAAQ,SAAS,KAG3B,QACJ,2BAA2B,QAAQ,UAAU,OAAO,GACpD,cAAc,QAAQ,UAAU,EAAE,QAAQ,CAAC;EAQ/C,GAAI,QAAQ,OAAO,SAAY,EAAE,IAAI,QAAQ,IAAI,GAAG,EAAE;EACvD,CAAC"}
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MongoContract, MongoContractWithTypeMaps, MongoTypeMaps } from "@prisma-next/mongo-contract";
|
|
2
2
|
import { mongoOrm } from "@prisma-next/mongo-orm";
|
|
3
|
-
import {
|
|
3
|
+
import { mongoQuery } from "@prisma-next/mongo-query-builder";
|
|
4
4
|
import { MongoRuntime } from "@prisma-next/mongo-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/runtime/mongo.d.ts
|
|
@@ -8,13 +8,13 @@ interface MongoOptions {
|
|
|
8
8
|
readonly contractJson: unknown;
|
|
9
9
|
}
|
|
10
10
|
interface MongoClient<TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>> {
|
|
11
|
-
readonly
|
|
11
|
+
readonly query: ReturnType<typeof mongoQuery<TContract>>;
|
|
12
12
|
connect(uri: string, dbName: string): Promise<ConnectedMongoClient<TContract>>;
|
|
13
13
|
}
|
|
14
14
|
interface ConnectedMongoClient<TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>> {
|
|
15
15
|
readonly orm: ReturnType<typeof mongoOrm<TContract>>;
|
|
16
16
|
readonly runtime: MongoRuntime;
|
|
17
|
-
readonly
|
|
17
|
+
readonly query: ReturnType<typeof mongoQuery<TContract>>;
|
|
18
18
|
readonly contract: TContract;
|
|
19
19
|
close(): Promise<void>;
|
|
20
20
|
}
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/runtime/mongo.ts"],"sourcesContent":[],"mappings":";;;;;;UAaiB,YAAA;;AAAjB;AAIiB,UAAA,WAAW,CAAA,kBACR,yBADQ,CACkB,aADlB,EACiC,aADjC,CAAA,CAAA,CAAA;EACkB,SAAA,
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/runtime/mongo.ts"],"sourcesContent":[],"mappings":";;;;;;UAaiB,YAAA;;AAAjB;AAIiB,UAAA,WAAW,CAAA,kBACR,yBADQ,CACkB,aADlB,EACiC,aADjC,CAAA,CAAA,CAAA;EACkB,SAAA,KAAA,EAE5B,UAF4B,CAAA,OAEV,UAFU,CAEC,SAFD,CAAA,CAAA;EAAe,OAAA,CAAA,GAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAGrB,OAHqB,CAGb,oBAHa,CAGQ,SAHR,CAAA,CAAA;;AAEd,UAI9B,oBAJ8B,CAAA,kBAK3B,yBAL2B,CAKD,aALC,EAKc,aALd,CAAA,CAAA,CAAA;EAAX,SAAA,GAAA,EAOpB,UAPoB,CAAA,OAOF,QAPE,CAOO,SAPP,CAAA,CAAA;EAAlB,SAAA,OAAA,EAQE,YARF;EACmD,SAAA,KAAA,EAQnD,UARmD,CAAA,OAQjC,UARiC,CAQtB,SARsB,CAAA,CAAA;EAArB,SAAA,QAAA,EAS3B,SAT2B;EAAR,KAAA,EAAA,EAU7B,OAV6B,CAAA,IAAA,CAAA;;AAGvB,iBAUO,KAVa,CAAA,kBAWjB,yBAXiB,CAWS,aAXT,EAWwB,aAXxB,CAAA,CAAA,CAAA,OAAA,EAY1B,YAZ0B,CAAA,EAYX,WAZW,CAYC,SAZD,CAAA"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -2,15 +2,15 @@ import { createMongoAdapter } from "@prisma-next/adapter-mongo";
|
|
|
2
2
|
import { createMongoDriver } from "@prisma-next/driver-mongo";
|
|
3
3
|
import { validateMongoContract } from "@prisma-next/mongo-contract";
|
|
4
4
|
import { mongoOrm } from "@prisma-next/mongo-orm";
|
|
5
|
-
import {
|
|
5
|
+
import { mongoQuery } from "@prisma-next/mongo-query-builder";
|
|
6
6
|
import { createMongoRuntime } from "@prisma-next/mongo-runtime";
|
|
7
7
|
|
|
8
8
|
//#region src/runtime/mongo.ts
|
|
9
9
|
function mongo(options) {
|
|
10
10
|
const { contract } = validateMongoContract(options.contractJson);
|
|
11
|
-
const
|
|
11
|
+
const query = mongoQuery({ contractJson: contract });
|
|
12
12
|
return {
|
|
13
|
-
|
|
13
|
+
query,
|
|
14
14
|
async connect(uri, dbName) {
|
|
15
15
|
const runtime = createMongoRuntime({
|
|
16
16
|
adapter: createMongoAdapter(),
|
|
@@ -24,7 +24,7 @@ function mongo(options) {
|
|
|
24
24
|
executor: runtime
|
|
25
25
|
}),
|
|
26
26
|
runtime,
|
|
27
|
-
|
|
27
|
+
query,
|
|
28
28
|
contract,
|
|
29
29
|
async close() {
|
|
30
30
|
await runtime.close();
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/runtime/mongo.ts"],"sourcesContent":["import { createMongoAdapter } from '@prisma-next/adapter-mongo';\nimport { createMongoDriver } from '@prisma-next/driver-mongo';\nimport type {\n MongoContract,\n MongoContractWithTypeMaps,\n MongoTypeMaps,\n} from '@prisma-next/mongo-contract';\nimport { validateMongoContract } from '@prisma-next/mongo-contract';\nimport { mongoOrm } from '@prisma-next/mongo-orm';\nimport {
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/runtime/mongo.ts"],"sourcesContent":["import { createMongoAdapter } from '@prisma-next/adapter-mongo';\nimport { createMongoDriver } from '@prisma-next/driver-mongo';\nimport type {\n MongoContract,\n MongoContractWithTypeMaps,\n MongoTypeMaps,\n} from '@prisma-next/mongo-contract';\nimport { validateMongoContract } from '@prisma-next/mongo-contract';\nimport { mongoOrm } from '@prisma-next/mongo-orm';\nimport { mongoQuery } from '@prisma-next/mongo-query-builder';\nimport type { MongoRuntime } from '@prisma-next/mongo-runtime';\nimport { createMongoRuntime } from '@prisma-next/mongo-runtime';\n\nexport interface MongoOptions {\n readonly contractJson: unknown;\n}\n\nexport interface MongoClient<\n TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>,\n> {\n readonly query: ReturnType<typeof mongoQuery<TContract>>;\n connect(uri: string, dbName: string): Promise<ConnectedMongoClient<TContract>>;\n}\n\nexport interface ConnectedMongoClient<\n TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>,\n> {\n readonly orm: ReturnType<typeof mongoOrm<TContract>>;\n readonly runtime: MongoRuntime;\n readonly query: ReturnType<typeof mongoQuery<TContract>>;\n readonly contract: TContract;\n close(): Promise<void>;\n}\n\nexport default function mongo<\n TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>,\n>(options: MongoOptions): MongoClient<TContract> {\n const { contract } = validateMongoContract<TContract>(options.contractJson);\n const query = mongoQuery<TContract>({ contractJson: contract });\n\n return {\n query,\n async connect(uri: string, dbName: string): Promise<ConnectedMongoClient<TContract>> {\n const adapter = createMongoAdapter();\n const driver = await createMongoDriver(uri, dbName);\n const runtime = createMongoRuntime({ adapter, driver, contract, targetId: 'mongo' });\n const orm = mongoOrm<TContract>({ contract, executor: runtime });\n\n return {\n orm,\n runtime,\n query,\n contract,\n async close() {\n await runtime.close();\n },\n };\n },\n };\n}\n"],"mappings":";;;;;;;;AAkCA,SAAwB,MAEtB,SAA+C;CAC/C,MAAM,EAAE,aAAa,sBAAiC,QAAQ,aAAa;CAC3E,MAAM,QAAQ,WAAsB,EAAE,cAAc,UAAU,CAAC;AAE/D,QAAO;EACL;EACA,MAAM,QAAQ,KAAa,QAA0D;GAGnF,MAAM,UAAU,mBAAmB;IAAE,SAFrB,oBAAoB;IAEU,QAD/B,MAAM,kBAAkB,KAAK,OAAO;IACG;IAAU,UAAU;IAAS,CAAC;AAGpF,UAAO;IACL,KAHU,SAAoB;KAAE;KAAU,UAAU;KAAS,CAAC;IAI9D;IACA;IACA;IACA,MAAM,QAAQ;AACZ,WAAM,QAAQ,OAAO;;IAExB;;EAEJ"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/mongo",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "One-package Mongo setup for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"pathe": "^2.0.3",
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/contract": "0.4.
|
|
12
|
-
"@prisma-next/
|
|
13
|
-
"@prisma-next/
|
|
14
|
-
"@prisma-next/
|
|
15
|
-
"@prisma-next/mongo-contract-psl": "0.4.
|
|
16
|
-
"@prisma-next/mongo
|
|
17
|
-
"@prisma-next/mongo-contract-ts": "0.4.
|
|
18
|
-
"@prisma-next/mongo-
|
|
19
|
-
"@prisma-next/mongo-
|
|
20
|
-
"@prisma-next/mongo-runtime": "0.4.
|
|
21
|
-
"@prisma-next/target-mongo": "0.4.
|
|
9
|
+
"@prisma-next/adapter-mongo": "0.4.1",
|
|
10
|
+
"@prisma-next/config": "0.4.1",
|
|
11
|
+
"@prisma-next/contract": "0.4.1",
|
|
12
|
+
"@prisma-next/framework-components": "0.4.1",
|
|
13
|
+
"@prisma-next/driver-mongo": "0.4.1",
|
|
14
|
+
"@prisma-next/mongo-contract": "0.4.1",
|
|
15
|
+
"@prisma-next/mongo-contract-psl": "0.4.1",
|
|
16
|
+
"@prisma-next/family-mongo": "0.4.1",
|
|
17
|
+
"@prisma-next/mongo-contract-ts": "0.4.1",
|
|
18
|
+
"@prisma-next/mongo-orm": "0.4.1",
|
|
19
|
+
"@prisma-next/mongo-query-builder": "0.4.1",
|
|
20
|
+
"@prisma-next/mongo-runtime": "0.4.1",
|
|
21
|
+
"@prisma-next/target-mongo": "0.4.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"tsdown": "0.18.4",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { pathToFileURL } from 'node:url';
|
|
2
1
|
import mongoAdapter from '@prisma-next/adapter-mongo/control';
|
|
3
|
-
import type {
|
|
2
|
+
import type { PrismaNextConfig } from '@prisma-next/config/config-types';
|
|
4
3
|
import { defineConfig as coreDefineConfig } from '@prisma-next/config/config-types';
|
|
5
4
|
import mongoDriver from '@prisma-next/driver-mongo/control';
|
|
6
5
|
import { mongoFamilyDescriptor, mongoTargetDescriptor } from '@prisma-next/family-mongo/control';
|
|
7
6
|
import { mongoContract } from '@prisma-next/mongo-contract-psl/provider';
|
|
8
|
-
import {
|
|
7
|
+
import { typescriptContractFromPath } from '@prisma-next/mongo-contract-ts/config-types';
|
|
8
|
+
import { extname } from 'pathe';
|
|
9
9
|
|
|
10
10
|
export interface MongoConfigOptions {
|
|
11
11
|
readonly contract: string;
|
|
@@ -26,23 +26,9 @@ export function defineConfig(options: MongoConfigOptions): PrismaNextConfig<'mon
|
|
|
26
26
|
const output = deriveOutputPath(options.contract);
|
|
27
27
|
const ext = extname(options.contract);
|
|
28
28
|
|
|
29
|
-
const absoluteContractPath = isAbsolute(options.contract)
|
|
30
|
-
? options.contract
|
|
31
|
-
: resolve(process.cwd(), options.contract);
|
|
32
|
-
|
|
33
29
|
const contractConfig =
|
|
34
30
|
ext === '.ts'
|
|
35
|
-
?
|
|
36
|
-
source: async (context: ContractSourceContext) => {
|
|
37
|
-
const { typescriptContract } = await import(
|
|
38
|
-
'@prisma-next/mongo-contract-ts/config-types'
|
|
39
|
-
);
|
|
40
|
-
const mod = await import(pathToFileURL(absoluteContractPath).href);
|
|
41
|
-
const contract = mod.default ?? mod.contract;
|
|
42
|
-
return typescriptContract(contract, output).source(context);
|
|
43
|
-
},
|
|
44
|
-
output,
|
|
45
|
-
}
|
|
31
|
+
? typescriptContractFromPath(options.contract, output)
|
|
46
32
|
: mongoContract(options.contract, { output });
|
|
47
33
|
|
|
48
34
|
return coreDefineConfig({
|
package/src/runtime/mongo.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
} from '@prisma-next/mongo-contract';
|
|
8
8
|
import { validateMongoContract } from '@prisma-next/mongo-contract';
|
|
9
9
|
import { mongoOrm } from '@prisma-next/mongo-orm';
|
|
10
|
-
import {
|
|
10
|
+
import { mongoQuery } from '@prisma-next/mongo-query-builder';
|
|
11
11
|
import type { MongoRuntime } from '@prisma-next/mongo-runtime';
|
|
12
12
|
import { createMongoRuntime } from '@prisma-next/mongo-runtime';
|
|
13
13
|
|
|
@@ -18,7 +18,7 @@ export interface MongoOptions {
|
|
|
18
18
|
export interface MongoClient<
|
|
19
19
|
TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>,
|
|
20
20
|
> {
|
|
21
|
-
readonly
|
|
21
|
+
readonly query: ReturnType<typeof mongoQuery<TContract>>;
|
|
22
22
|
connect(uri: string, dbName: string): Promise<ConnectedMongoClient<TContract>>;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ export interface ConnectedMongoClient<
|
|
|
27
27
|
> {
|
|
28
28
|
readonly orm: ReturnType<typeof mongoOrm<TContract>>;
|
|
29
29
|
readonly runtime: MongoRuntime;
|
|
30
|
-
readonly
|
|
30
|
+
readonly query: ReturnType<typeof mongoQuery<TContract>>;
|
|
31
31
|
readonly contract: TContract;
|
|
32
32
|
close(): Promise<void>;
|
|
33
33
|
}
|
|
@@ -36,10 +36,10 @@ export default function mongo<
|
|
|
36
36
|
TContract extends MongoContractWithTypeMaps<MongoContract, MongoTypeMaps>,
|
|
37
37
|
>(options: MongoOptions): MongoClient<TContract> {
|
|
38
38
|
const { contract } = validateMongoContract<TContract>(options.contractJson);
|
|
39
|
-
const
|
|
39
|
+
const query = mongoQuery<TContract>({ contractJson: contract });
|
|
40
40
|
|
|
41
41
|
return {
|
|
42
|
-
|
|
42
|
+
query,
|
|
43
43
|
async connect(uri: string, dbName: string): Promise<ConnectedMongoClient<TContract>> {
|
|
44
44
|
const adapter = createMongoAdapter();
|
|
45
45
|
const driver = await createMongoDriver(uri, dbName);
|
|
@@ -49,7 +49,7 @@ export default function mongo<
|
|
|
49
49
|
return {
|
|
50
50
|
orm,
|
|
51
51
|
runtime,
|
|
52
|
-
|
|
52
|
+
query,
|
|
53
53
|
contract,
|
|
54
54
|
async close() {
|
|
55
55
|
await runtime.close();
|