MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / loadSchemaDocument

Function loadSchemaDocument

packages/cli/src/actions/action-utils.ts:59–80  ·  view source on GitHub ↗
(
    schemaFile: string,
    opts: { returnServices?: boolean; mergeImports?: boolean } = {},
)

Source from the content-addressed store, hash-verified

57 opts: { returnServices: true; mergeImports?: boolean },
58): Promise<{ model: Model; services: ZModelServices }>;
59export async function loadSchemaDocument(
60 schemaFile: string,
61 opts: { returnServices?: boolean; mergeImports?: boolean } = {},
62) {
63 const returnServices = opts.returnServices ?? false;
64 const mergeImports = opts.mergeImports ?? true;
65
66 const loadResult = await loadDocument(schemaFile, [], mergeImports);
67 if (!loadResult.success) {
68 loadResult.errors.forEach((err) => {
69 console.error(colors.red(err));
70 });
71 throw new CliError('Schema contains errors. See above for details.');
72 }
73 loadResult.warnings.forEach((warn) => {
74 console.warn(colors.yellow(warn));
75 });
76
77 if (returnServices) return { model: loadResult.model, services: loadResult.services };
78
79 return loadResult.model;
80}
81
82export function handleSubProcessError(err: unknown) {
83 if (err instanceof Error && 'status' in err && typeof err.status === 'number') {

Callers 6

runFunction · 0.90
pureGenerateFunction · 0.90
runPullFunction · 0.90
runFunction · 0.90
generateTempPrismaSchemaFunction · 0.85
requireDataSourceUrlFunction · 0.85

Calls 1

loadDocumentFunction · 0.90

Tested by

no test coverage detected