@prisma/schema-files-loader
Advanced tools
Comparing version 6.4.0-integration-renovate-configure.1 to 6.4.0-integration-studio-release-version-05090.1
@@ -27,2 +27,4 @@ export declare type CaseSensitivityOptions = { | ||
export declare function ensureType(entryPath: string, expectedType: PathType): Promise<NonFatalLookupError | undefined>; | ||
export declare interface FilesResolver { | ||
@@ -49,2 +51,21 @@ listDirContents(path: string): Promise<string[]>; | ||
export declare type GetSchemaResult = { | ||
/** | ||
* A path from which schema was loaded. | ||
* Can be either folder or a single file | ||
*/ | ||
schemaPath: string; | ||
/** | ||
* Base dir for all of the schema files. | ||
* In-multi file mode, this is equal to `schemaPath`. | ||
* In single-file mode, this is a parent directory of | ||
* a file | ||
*/ | ||
schemaRootDir: string; | ||
/** | ||
* All loaded schema files | ||
*/ | ||
schemas: Array<LoadedFile>; | ||
}; | ||
export declare class InMemoryFilesResolver implements FilesResolver { | ||
@@ -78,6 +99,31 @@ private _tree; | ||
export declare type LookupResult = SuccessfulLookupResult | { | ||
ok: false; | ||
error: NonFatalLookupError; | ||
}; | ||
export declare type NonFatalLookupError = { | ||
kind: 'NotFound'; | ||
expectedType?: PathType; | ||
path: string; | ||
} | { | ||
kind: 'WrongType'; | ||
path: string; | ||
expectedTypes: PathType[]; | ||
} | { | ||
kind: 'FolderPreviewNotEnabled'; | ||
path: string; | ||
}; | ||
export declare type PathType = 'file' | 'directory'; | ||
export declare const realFsResolver: FilesResolver; | ||
export declare type SuccessfulLookupResult = { | ||
ok: true; | ||
schema: GetSchemaResult; | ||
}; | ||
export declare function usesPrismaSchemaFolder(config: ConfigMetaFormat): boolean; | ||
export { } |
@@ -35,2 +35,3 @@ "use strict"; | ||
InMemoryFilesResolver: () => InMemoryFilesResolver, | ||
ensureType: () => ensureType, | ||
loadRelatedSchemaFiles: () => loadRelatedSchemaFiles, | ||
@@ -284,2 +285,22 @@ loadSchemaFiles: () => loadSchemaFiles, | ||
} | ||
// src/utils/ensureType.ts | ||
var import_promises = __toESM(require("node:fs/promises")); | ||
async function ensureType(entryPath, expectedType) { | ||
try { | ||
const pathStat = await import_promises.default.stat(entryPath); | ||
if (expectedType === "file" && pathStat.isFile()) { | ||
return void 0; | ||
} | ||
if (expectedType === "directory" && pathStat.isDirectory()) { | ||
return void 0; | ||
} | ||
return { kind: "WrongType", path: entryPath, expectedTypes: [expectedType] }; | ||
} catch (e) { | ||
if (e.code === "ENOENT") { | ||
return { kind: "NotFound", path: entryPath, expectedType }; | ||
} | ||
throw e; | ||
} | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -289,2 +310,3 @@ 0 && (module.exports = { | ||
InMemoryFilesResolver, | ||
ensureType, | ||
loadRelatedSchemaFiles, | ||
@@ -291,0 +313,0 @@ loadSchemaFiles, |
{ | ||
"name": "@prisma/schema-files-loader", | ||
"version": "6.4.0-integration-renovate-configure.1", | ||
"version": "6.4.0-integration-studio-release-version-05090.1", | ||
"description": "Package for resolving and loading schema files when schema is split into multiple files", | ||
@@ -19,3 +19,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@prisma/prisma-schema-wasm": "6.4.0-22.6b762f68259116818698cc00c29790aebfc0e55e", | ||
"@prisma/prisma-schema-wasm": "6.4.0-29.a9055b89e58b4b5bfb59600785423b1db3d0e75d", | ||
"fs-extra": "11.1.1" | ||
@@ -22,0 +22,0 @@ }, |
26378
410