@prisma/schema-files-loader 6.7.0-dev.7 → 6.7.0-dev.9
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/index.d.ts +0 -15
- package/dist/index.js +3 -30
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -18,12 +18,6 @@ export declare class CompositeFilesResolver implements FilesResolver {
|
|
|
18
18
|
getFileContents(path: string): Promise<string | undefined>;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export declare type ConfigMetaFormat = {
|
|
22
|
-
generators: Array<{
|
|
23
|
-
previewFeatures: string[];
|
|
24
|
-
}>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
21
|
export declare function ensureType(entryPath: string, expectedType: PathType): Promise<NonFatalLookupError | undefined>;
|
|
28
22
|
|
|
29
23
|
export declare interface FilesResolver {
|
|
@@ -43,10 +37,6 @@ export declare type FsEntryType = {
|
|
|
43
37
|
kind: 'other';
|
|
44
38
|
};
|
|
45
39
|
|
|
46
|
-
export declare type GetConfigResponse = {
|
|
47
|
-
config: ConfigMetaFormat;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
40
|
export declare type GetSchemaResult = {
|
|
51
41
|
/**
|
|
52
42
|
* A path from which schema was loaded.
|
|
@@ -107,9 +97,6 @@ export declare type NonFatalLookupError = {
|
|
|
107
97
|
kind: 'WrongType';
|
|
108
98
|
path: string;
|
|
109
99
|
expectedTypes: PathType[];
|
|
110
|
-
} | {
|
|
111
|
-
kind: 'FolderPreviewNotEnabled';
|
|
112
|
-
path: string;
|
|
113
100
|
};
|
|
114
101
|
|
|
115
102
|
export declare type PathType = 'file' | 'directory';
|
|
@@ -121,6 +108,4 @@ export declare type SuccessfulLookupResult = {
|
|
|
121
108
|
schema: GetSchemaResult;
|
|
122
109
|
};
|
|
123
110
|
|
|
124
|
-
export declare function usesPrismaSchemaFolder(config: ConfigMetaFormat): boolean;
|
|
125
|
-
|
|
126
111
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -35,14 +35,12 @@ __export(index_exports, {
|
|
|
35
35
|
ensureType: () => ensureType,
|
|
36
36
|
loadRelatedSchemaFiles: () => loadRelatedSchemaFiles,
|
|
37
37
|
loadSchemaFiles: () => loadSchemaFiles,
|
|
38
|
-
realFsResolver: () => realFsResolver
|
|
39
|
-
usesPrismaSchemaFolder: () => usesPrismaSchemaFolder
|
|
38
|
+
realFsResolver: () => realFsResolver
|
|
40
39
|
});
|
|
41
40
|
module.exports = __toCommonJS(index_exports);
|
|
42
41
|
|
|
43
42
|
// src/loadRelatedSchemaFiles.ts
|
|
44
43
|
var import_node_path2 = __toESM(require("node:path"));
|
|
45
|
-
var import_prisma_schema_wasm = require("@prisma/prisma-schema-wasm");
|
|
46
44
|
|
|
47
45
|
// src/loadSchemaFiles.ts
|
|
48
46
|
var import_node_path = __toESM(require("node:path"));
|
|
@@ -231,23 +229,13 @@ async function processEntry(entryPath, entryType, filesResolver) {
|
|
|
231
229
|
return [];
|
|
232
230
|
}
|
|
233
231
|
|
|
234
|
-
// src/usesPrismaSchemaFolder.ts
|
|
235
|
-
function usesPrismaSchemaFolder(config) {
|
|
236
|
-
const previewFeatures = config.generators.find((g) => g.previewFeatures.length > 0)?.previewFeatures;
|
|
237
|
-
return (previewFeatures || []).includes("prismaSchemaFolder");
|
|
238
|
-
}
|
|
239
|
-
|
|
240
232
|
// src/loadRelatedSchemaFiles.ts
|
|
241
233
|
async function loadRelatedSchemaFiles(filePath, filesResolver = realFsResolver) {
|
|
242
234
|
const rootDir = await findSchemaRoot(filePath, filesResolver);
|
|
243
235
|
if (!rootDir) {
|
|
244
236
|
return singleFile(filePath, filesResolver);
|
|
245
237
|
}
|
|
246
|
-
|
|
247
|
-
if (isPrismaFolderEnabled(files)) {
|
|
248
|
-
return files;
|
|
249
|
-
}
|
|
250
|
-
return singleFile(filePath, filesResolver);
|
|
238
|
+
return await loadSchemaFiles(rootDir, filesResolver);
|
|
251
239
|
}
|
|
252
240
|
async function singleFile(filePath, filesResolver) {
|
|
253
241
|
const contents = await filesResolver.getFileContents(filePath);
|
|
@@ -256,20 +244,6 @@ async function singleFile(filePath, filesResolver) {
|
|
|
256
244
|
}
|
|
257
245
|
return [[filePath, contents]];
|
|
258
246
|
}
|
|
259
|
-
function isPrismaFolderEnabled(files) {
|
|
260
|
-
const params = JSON.stringify({
|
|
261
|
-
prismaSchema: files,
|
|
262
|
-
datasourceOverrides: {},
|
|
263
|
-
ignoreEnvVarErrors: true,
|
|
264
|
-
env: {}
|
|
265
|
-
});
|
|
266
|
-
try {
|
|
267
|
-
const response = JSON.parse((0, import_prisma_schema_wasm.get_config)(params));
|
|
268
|
-
return usesPrismaSchemaFolder(response.config);
|
|
269
|
-
} catch (e) {
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
247
|
async function findSchemaRoot(filePath, filesResolver) {
|
|
274
248
|
let dir = import_node_path2.default.dirname(filePath);
|
|
275
249
|
while (dir !== filePath) {
|
|
@@ -310,6 +284,5 @@ async function ensureType(entryPath, expectedType) {
|
|
|
310
284
|
ensureType,
|
|
311
285
|
loadRelatedSchemaFiles,
|
|
312
286
|
loadSchemaFiles,
|
|
313
|
-
realFsResolver
|
|
314
|
-
usesPrismaSchemaFolder
|
|
287
|
+
realFsResolver
|
|
315
288
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/schema-files-loader",
|
|
3
|
-
"version": "6.7.0-dev.
|
|
3
|
+
"version": "6.7.0-dev.9",
|
|
4
4
|
"description": "Package for resolving and loading schema files when schema is split into multiple files",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"sideEffects": false,
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@prisma/prisma-schema-wasm": "6.7.0-
|
|
19
|
+
"@prisma/prisma-schema-wasm": "6.7.0-5.86e95ba127659d2076fd5a902b2a6f3921fc2d2c",
|
|
20
20
|
"fs-extra": "11.3.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|