@zenstackhq/cli 3.4.2 → 3.4.4

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.js CHANGED
@@ -18,16 +18,23 @@ import colors12 from "colors";
18
18
  import { Command, CommanderError, Option } from "commander";
19
19
 
20
20
  // src/actions/check.ts
21
+ import { isPlugin } from "@zenstackhq/language/ast";
21
22
  import colors2 from "colors";
23
+ import path2 from "path";
22
24
 
23
25
  // src/actions/action-utils.ts
26
+ import { invariant } from "@zenstackhq/common-helpers";
24
27
  import { loadDocument } from "@zenstackhq/language";
25
28
  import { isDataSource } from "@zenstackhq/language/ast";
26
29
  import { PrismaSchemaGenerator } from "@zenstackhq/sdk";
27
30
  import colors from "colors";
31
+ import { createJiti } from "jiti";
28
32
  import fs from "fs";
29
33
  import { createRequire } from "module";
30
34
  import path from "path";
35
+ import { pathToFileURL } from "url";
36
+ import terminalLink from "terminal-link";
37
+ import { z } from "zod";
31
38
 
32
39
  // src/cli-error.ts
33
40
  var CliError = class extends Error {
@@ -37,8 +44,6 @@ var CliError = class extends Error {
37
44
  };
38
45
 
39
46
  // src/actions/action-utils.ts
40
- import terminalLink from "terminal-link";
41
- import { z } from "zod";
42
47
  function getSchemaFile(file) {
43
48
  if (file) {
44
49
  if (!fs.existsSync(file)) {
@@ -214,6 +219,80 @@ async function getZenStackPackages(searchPath) {
214
219
  return result.filter((p) => !!p);
215
220
  }
216
221
  __name(getZenStackPackages, "getZenStackPackages");
222
+ function getPluginProvider(plugin3) {
223
+ const providerField = plugin3.fields.find((f) => f.name === "provider");
224
+ invariant(providerField, `Plugin ${plugin3.name} does not have a provider field`);
225
+ const provider = providerField.value.value;
226
+ return provider;
227
+ }
228
+ __name(getPluginProvider, "getPluginProvider");
229
+ async function loadPluginModule(provider, basePath) {
230
+ if (provider.toLowerCase().endsWith(".zmodel")) {
231
+ return void 0;
232
+ }
233
+ let moduleSpec = provider;
234
+ if (moduleSpec.startsWith(".")) {
235
+ moduleSpec = path.resolve(basePath, moduleSpec);
236
+ }
237
+ const importAsEsm = /* @__PURE__ */ __name(async (spec) => {
238
+ try {
239
+ const result = (await import(spec)).default;
240
+ return result;
241
+ } catch (err) {
242
+ throw new CliError(`Failed to load plugin module from ${spec}: ${err.message}`);
243
+ }
244
+ }, "importAsEsm");
245
+ const jiti = createJiti(pathToFileURL(basePath).toString());
246
+ const importAsTs = /* @__PURE__ */ __name(async (spec) => {
247
+ try {
248
+ const result = await jiti.import(spec, {
249
+ default: true
250
+ });
251
+ return result;
252
+ } catch (err) {
253
+ throw new CliError(`Failed to load plugin module from ${spec}: ${err.message}`);
254
+ }
255
+ }, "importAsTs");
256
+ const esmSuffixes = [
257
+ ".js",
258
+ ".mjs"
259
+ ];
260
+ const tsSuffixes = [
261
+ ".ts",
262
+ ".mts"
263
+ ];
264
+ if (fs.existsSync(moduleSpec) && fs.statSync(moduleSpec).isFile()) {
265
+ if (esmSuffixes.some((suffix) => moduleSpec.endsWith(suffix))) {
266
+ return await importAsEsm(pathToFileURL(moduleSpec).toString());
267
+ }
268
+ if (tsSuffixes.some((suffix) => moduleSpec.endsWith(suffix))) {
269
+ return await importAsTs(moduleSpec);
270
+ }
271
+ }
272
+ for (const suffix of esmSuffixes) {
273
+ const indexPath = path.join(moduleSpec, `index${suffix}`);
274
+ if (fs.existsSync(indexPath)) {
275
+ return await importAsEsm(pathToFileURL(indexPath).toString());
276
+ }
277
+ }
278
+ for (const suffix of tsSuffixes) {
279
+ const indexPath = path.join(moduleSpec, `index${suffix}`);
280
+ if (fs.existsSync(indexPath)) {
281
+ return await importAsTs(indexPath);
282
+ }
283
+ }
284
+ try {
285
+ const mod = await import(moduleSpec);
286
+ return mod.default;
287
+ } catch (err) {
288
+ const errorCode = err?.code;
289
+ if (errorCode === "ERR_MODULE_NOT_FOUND" || errorCode === "MODULE_NOT_FOUND") {
290
+ throw new CliError(`Cannot find plugin module "${provider}". Please make sure the package exists.`);
291
+ }
292
+ throw new CliError(`Failed to load plugin module "${provider}": ${err.message}`);
293
+ }
294
+ }
295
+ __name(loadPluginModule, "loadPluginModule");
217
296
  var FETCH_CLI_MAX_TIME = 1e3;
218
297
  var CLI_CONFIG_ENDPOINT = "https://zenstack.dev/config/cli-v3.json";
219
298
  var usageTipsSchema = z.object({
@@ -271,7 +350,8 @@ __name(startUsageTipsFetch, "startUsageTipsFetch");
271
350
  async function run(options) {
272
351
  const schemaFile = getSchemaFile(options.schema);
273
352
  try {
274
- await loadSchemaDocument(schemaFile);
353
+ const model = await loadSchemaDocument(schemaFile);
354
+ await checkPluginResolution(schemaFile, model);
275
355
  console.log(colors2.green("\u2713 Schema validation completed successfully."));
276
356
  } catch (error) {
277
357
  console.error(colors2.red("\u2717 Schema validation failed."));
@@ -279,13 +359,23 @@ async function run(options) {
279
359
  }
280
360
  }
281
361
  __name(run, "run");
362
+ async function checkPluginResolution(schemaFile, model) {
363
+ const plugins = model.declarations.filter(isPlugin);
364
+ for (const plugin3 of plugins) {
365
+ const provider = getPluginProvider(plugin3);
366
+ if (!provider.startsWith("@core/")) {
367
+ await loadPluginModule(provider, path2.dirname(schemaFile));
368
+ }
369
+ }
370
+ }
371
+ __name(checkPluginResolution, "checkPluginResolution");
282
372
 
283
373
  // src/actions/db.ts
284
374
  import { formatDocument, ZModelCodeGenerator } from "@zenstackhq/language";
285
375
  import { DataModel, Enum } from "@zenstackhq/language/ast";
286
376
  import colors4 from "colors";
287
377
  import fs2 from "fs";
288
- import path2 from "path";
378
+ import path3 from "path";
289
379
  import ora from "ora";
290
380
 
291
381
  // src/utils/exec-utils.ts
@@ -2246,7 +2336,7 @@ var sqlite = {
2246
2336
  const stmt = db.prepare(sql);
2247
2337
  return stmt.all();
2248
2338
  }, "all");
2249
- const tablesRaw = all("SELECT name, type, sql AS definition FROM sqlite_schema WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' ORDER BY name");
2339
+ const tablesRaw = all("SELECT name, type, sql AS definition FROM sqlite_schema WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%' AND name <> '_prisma_migrations' ORDER BY name");
2250
2340
  const autoIncrementTables = /* @__PURE__ */ new Set();
2251
2341
  for (const t of tablesRaw) {
2252
2342
  if (t.type === "table" && t.definition) {
@@ -2516,8 +2606,8 @@ async function runPull(options) {
2516
2606
  const spinner = ora();
2517
2607
  try {
2518
2608
  const schemaFile = getSchemaFile(options.schema);
2519
- const outPath = options.output ? path2.resolve(options.output) : void 0;
2520
- const treatAsFile = !!outPath && (fs2.existsSync(outPath) && fs2.lstatSync(outPath).isFile() || path2.extname(outPath) !== "");
2609
+ const outPath = options.output ? path3.resolve(options.output) : void 0;
2610
+ const treatAsFile = !!outPath && (fs2.existsSync(outPath) && fs2.lstatSync(outPath).isFile() || path3.extname(outPath) !== "");
2521
2611
  const { model, services } = await loadSchemaDocument(schemaFile, {
2522
2612
  returnServices: true,
2523
2613
  mergeImports: treatAsFile
@@ -2591,7 +2681,7 @@ async function runPull(options) {
2591
2681
  oldModel: model
2592
2682
  });
2593
2683
  console.log(colors4.blue("Schema synced"));
2594
- const baseDir = path2.dirname(path2.resolve(schemaFile));
2684
+ const baseDir = path3.dirname(path3.resolve(schemaFile));
2595
2685
  const baseDirUrlPath = new URL(`file://${baseDir}`).pathname;
2596
2686
  const docs = services.shared.workspace.LangiumDocuments.all.filter(({ uri }) => uri.path.toLowerCase().startsWith(baseDirUrlPath.toLowerCase())).toArray();
2597
2687
  const docsSet = new Set(docs.map((d) => d.uri.toString()));
@@ -2876,7 +2966,7 @@ async function runPull(options) {
2876
2966
  if (treatAsFile) {
2877
2967
  const zmodelSchema = await formatDocument(generator.generate(newModel));
2878
2968
  console.log(colors4.blue(`Writing to ${outPath}`));
2879
- fs2.mkdirSync(path2.dirname(outPath), {
2969
+ fs2.mkdirSync(path3.dirname(outPath), {
2880
2970
  recursive: true
2881
2971
  });
2882
2972
  fs2.writeFileSync(outPath, zmodelSchema);
@@ -2884,12 +2974,12 @@ async function runPull(options) {
2884
2974
  fs2.mkdirSync(outPath, {
2885
2975
  recursive: true
2886
2976
  });
2887
- const baseDir2 = path2.dirname(path2.resolve(schemaFile));
2977
+ const baseDir2 = path3.dirname(path3.resolve(schemaFile));
2888
2978
  for (const { uri, parseResult: { value: documentModel } } of docs) {
2889
2979
  const zmodelSchema = await formatDocument(generator.generate(documentModel));
2890
- const relPath = path2.relative(baseDir2, uri.fsPath);
2891
- const targetFile = path2.join(outPath, relPath);
2892
- fs2.mkdirSync(path2.dirname(targetFile), {
2980
+ const relPath = path3.relative(baseDir2, uri.fsPath);
2981
+ const targetFile = path3.join(outPath, relPath);
2982
+ fs2.mkdirSync(path3.dirname(targetFile), {
2893
2983
  recursive: true
2894
2984
  });
2895
2985
  console.log(colors4.blue(`Writing to ${targetFile}`));
@@ -2899,7 +2989,7 @@ async function runPull(options) {
2899
2989
  } else {
2900
2990
  for (const { uri, parseResult: { value: documentModel } } of docs) {
2901
2991
  const zmodelSchema = await formatDocument(generator.generate(documentModel));
2902
- console.log(colors4.blue(`Writing to ${path2.relative(process.cwd(), uri.fsPath).replace(/\\/g, "/")}`));
2992
+ console.log(colors4.blue(`Writing to ${path3.relative(process.cwd(), uri.fsPath).replace(/\\/g, "/")}`));
2903
2993
  fs2.writeFileSync(uri.fsPath, zmodelSchema);
2904
2994
  }
2905
2995
  }
@@ -2931,16 +3021,13 @@ async function run3(options) {
2931
3021
  __name(run3, "run");
2932
3022
 
2933
3023
  // src/actions/generate.ts
2934
- import { invariant, singleDebounce } from "@zenstackhq/common-helpers";
3024
+ import { invariant as invariant2, singleDebounce } from "@zenstackhq/common-helpers";
2935
3025
  import { ZModelLanguageMetaData } from "@zenstackhq/language";
2936
- import { isPlugin } from "@zenstackhq/language/ast";
3026
+ import { isPlugin as isPlugin2 } from "@zenstackhq/language/ast";
2937
3027
  import { getLiteral, getLiteralArray as getLiteralArray2 } from "@zenstackhq/language/utils";
2938
3028
  import { watch } from "chokidar";
2939
3029
  import colors6 from "colors";
2940
- import { createJiti } from "jiti";
2941
- import fs6 from "fs";
2942
- import path5 from "path";
2943
- import { pathToFileURL } from "url";
3030
+ import path6 from "path";
2944
3031
  import ora2 from "ora";
2945
3032
  import semver from "semver";
2946
3033
 
@@ -2954,16 +3041,16 @@ __export(plugins_exports, {
2954
3041
  // src/plugins/prisma.ts
2955
3042
  import { PrismaSchemaGenerator as PrismaSchemaGenerator2 } from "@zenstackhq/sdk";
2956
3043
  import fs4 from "fs";
2957
- import path3 from "path";
3044
+ import path4 from "path";
2958
3045
  var plugin = {
2959
3046
  name: "Prisma Schema Generator",
2960
3047
  statusText: "Generating Prisma schema",
2961
3048
  async generate({ model, defaultOutputPath, pluginOptions }) {
2962
- let outFile = path3.join(defaultOutputPath, "schema.prisma");
3049
+ let outFile = path4.join(defaultOutputPath, "schema.prisma");
2963
3050
  if (typeof pluginOptions["output"] === "string") {
2964
- outFile = path3.resolve(defaultOutputPath, pluginOptions["output"]);
2965
- if (!fs4.existsSync(path3.dirname(outFile))) {
2966
- fs4.mkdirSync(path3.dirname(outFile), {
3051
+ outFile = path4.resolve(defaultOutputPath, pluginOptions["output"]);
3052
+ if (!fs4.existsSync(path4.dirname(outFile))) {
3053
+ fs4.mkdirSync(path4.dirname(outFile), {
2967
3054
  recursive: true
2968
3055
  });
2969
3056
  }
@@ -2977,14 +3064,14 @@ var prisma_default = plugin;
2977
3064
  // src/plugins/typescript.ts
2978
3065
  import { TsSchemaGenerator } from "@zenstackhq/sdk";
2979
3066
  import fs5 from "fs";
2980
- import path4 from "path";
3067
+ import path5 from "path";
2981
3068
  var plugin2 = {
2982
3069
  name: "TypeScript Schema Generator",
2983
3070
  statusText: "Generating TypeScript schema",
2984
3071
  async generate({ model, defaultOutputPath, pluginOptions }) {
2985
3072
  let outDir = defaultOutputPath;
2986
3073
  if (typeof pluginOptions["output"] === "string") {
2987
- outDir = path4.resolve(defaultOutputPath, pluginOptions["output"]);
3074
+ outDir = path5.resolve(defaultOutputPath, pluginOptions["output"]);
2988
3075
  if (!fs5.existsSync(outDir)) {
2989
3076
  fs5.mkdirSync(outDir, {
2990
3077
  recursive: true
@@ -3108,7 +3195,7 @@ async function pureGenerate(options, fromWatch) {
3108
3195
 
3109
3196
  \`\`\`ts
3110
3197
  import { ZenStackClient } from '@zenstackhq/orm';
3111
- import { schema } from '${path5.relative(".", outputPath)}/schema';
3198
+ import { schema } from '${path6.relative(".", outputPath)}/schema';
3112
3199
 
3113
3200
  const client = new ZenStackClient(schema, {
3114
3201
  dialect: { ... }
@@ -3122,7 +3209,7 @@ Check documentation: https://zenstack.dev/docs/`);
3122
3209
  }
3123
3210
  __name(pureGenerate, "pureGenerate");
3124
3211
  async function runPlugins(schemaFile, model, outputPath, options) {
3125
- const plugins = model.declarations.filter(isPlugin);
3212
+ const plugins = model.declarations.filter(isPlugin2);
3126
3213
  const processedPlugins = [];
3127
3214
  for (const plugin3 of plugins) {
3128
3215
  const provider = getPluginProvider(plugin3);
@@ -3133,7 +3220,7 @@ async function runPlugins(schemaFile, model, outputPath, options) {
3133
3220
  throw new CliError(`Unknown core plugin: ${provider}`);
3134
3221
  }
3135
3222
  } else {
3136
- cliPlugin = await loadPluginModule(provider, path5.dirname(schemaFile));
3223
+ cliPlugin = await loadPluginModule(provider, path6.dirname(schemaFile));
3137
3224
  }
3138
3225
  if (cliPlugin) {
3139
3226
  const pluginOptions = getPluginOptions(plugin3);
@@ -3177,7 +3264,7 @@ async function runPlugins(schemaFile, model, outputPath, options) {
3177
3264
  }
3178
3265
  });
3179
3266
  for (const { cliPlugin, pluginOptions } of processedPlugins) {
3180
- invariant(typeof cliPlugin.generate === "function", `Plugin ${cliPlugin.name} does not have a generate function`);
3267
+ invariant2(typeof cliPlugin.generate === "function", `Plugin ${cliPlugin.name} does not have a generate function`);
3181
3268
  let spinner;
3182
3269
  if (!options.silent) {
3183
3270
  spinner = ora2(cliPlugin.statusText ?? `Running plugin ${cliPlugin.name}`).start();
@@ -3197,13 +3284,6 @@ async function runPlugins(schemaFile, model, outputPath, options) {
3197
3284
  }
3198
3285
  }
3199
3286
  __name(runPlugins, "runPlugins");
3200
- function getPluginProvider(plugin3) {
3201
- const providerField = plugin3.fields.find((f) => f.name === "provider");
3202
- invariant(providerField, `Plugin ${plugin3.name} does not have a provider field`);
3203
- const provider = providerField.value.value;
3204
- return provider;
3205
- }
3206
- __name(getPluginProvider, "getPluginProvider");
3207
3287
  function getPluginOptions(plugin3) {
3208
3288
  const result = {};
3209
3289
  for (const field of plugin3.fields) {
@@ -3220,65 +3300,6 @@ function getPluginOptions(plugin3) {
3220
3300
  return result;
3221
3301
  }
3222
3302
  __name(getPluginOptions, "getPluginOptions");
3223
- async function loadPluginModule(provider, basePath) {
3224
- let moduleSpec = provider;
3225
- if (moduleSpec.startsWith(".")) {
3226
- moduleSpec = path5.resolve(basePath, moduleSpec);
3227
- }
3228
- const importAsEsm = /* @__PURE__ */ __name(async (spec) => {
3229
- try {
3230
- const result = (await import(spec)).default;
3231
- return result;
3232
- } catch (err) {
3233
- throw new CliError(`Failed to load plugin module from ${spec}: ${err.message}`);
3234
- }
3235
- }, "importAsEsm");
3236
- const jiti = createJiti(pathToFileURL(basePath).toString());
3237
- const importAsTs = /* @__PURE__ */ __name(async (spec) => {
3238
- try {
3239
- const result = await jiti.import(spec, {
3240
- default: true
3241
- });
3242
- return result;
3243
- } catch (err) {
3244
- throw new CliError(`Failed to load plugin module from ${spec}: ${err.message}`);
3245
- }
3246
- }, "importAsTs");
3247
- const esmSuffixes = [
3248
- ".js",
3249
- ".mjs"
3250
- ];
3251
- const tsSuffixes = [
3252
- ".ts",
3253
- ".mts"
3254
- ];
3255
- if (fs6.existsSync(moduleSpec) && fs6.statSync(moduleSpec).isFile()) {
3256
- if (esmSuffixes.some((suffix) => moduleSpec.endsWith(suffix))) {
3257
- return await importAsEsm(pathToFileURL(moduleSpec).toString());
3258
- }
3259
- if (tsSuffixes.some((suffix) => moduleSpec.endsWith(suffix))) {
3260
- return await importAsTs(moduleSpec);
3261
- }
3262
- }
3263
- for (const suffix of esmSuffixes) {
3264
- const indexPath = path5.join(moduleSpec, `index${suffix}`);
3265
- if (fs6.existsSync(indexPath)) {
3266
- return await importAsEsm(pathToFileURL(indexPath).toString());
3267
- }
3268
- }
3269
- for (const suffix of tsSuffixes) {
3270
- const indexPath = path5.join(moduleSpec, `index${suffix}`);
3271
- if (fs6.existsSync(indexPath)) {
3272
- return await importAsTs(indexPath);
3273
- }
3274
- }
3275
- try {
3276
- return (await import(moduleSpec)).default;
3277
- } catch {
3278
- return void 0;
3279
- }
3280
- }
3281
- __name(loadPluginModule, "loadPluginModule");
3282
3303
  async function checkForMismatchedPackages(projectPath) {
3283
3304
  const packages = await getZenStackPackages(projectPath);
3284
3305
  if (!packages.length) {
@@ -3338,8 +3359,8 @@ __name(run5, "run");
3338
3359
 
3339
3360
  // src/actions/init.ts
3340
3361
  import colors8 from "colors";
3341
- import fs7 from "fs";
3342
- import path6 from "path";
3362
+ import fs6 from "fs";
3363
+ import path7 from "path";
3343
3364
  import ora3 from "ora";
3344
3365
  import { detect, resolveCommand } from "package-manager-detector";
3345
3366
 
@@ -3379,6 +3400,10 @@ async function run6(projectPath) {
3379
3400
  name: "@zenstackhq/cli@latest",
3380
3401
  dev: true
3381
3402
  },
3403
+ {
3404
+ name: "@zenstackhq/schema@latest",
3405
+ dev: false
3406
+ },
3382
3407
  {
3383
3408
  name: "@zenstackhq/orm@latest",
3384
3409
  dev: false
@@ -3414,11 +3439,11 @@ async function run6(projectPath) {
3414
3439
  }
3415
3440
  }
3416
3441
  const generationFolder = "zenstack";
3417
- if (!fs7.existsSync(path6.join(projectPath, generationFolder))) {
3418
- fs7.mkdirSync(path6.join(projectPath, generationFolder));
3442
+ if (!fs6.existsSync(path7.join(projectPath, generationFolder))) {
3443
+ fs6.mkdirSync(path7.join(projectPath, generationFolder));
3419
3444
  }
3420
- if (!fs7.existsSync(path6.join(projectPath, generationFolder, "schema.zmodel"))) {
3421
- fs7.writeFileSync(path6.join(projectPath, generationFolder, "schema.zmodel"), STARTER_ZMODEL);
3445
+ if (!fs6.existsSync(path7.join(projectPath, generationFolder, "schema.zmodel"))) {
3446
+ fs6.writeFileSync(path7.join(projectPath, generationFolder, "schema.zmodel"), STARTER_ZMODEL);
3422
3447
  } else {
3423
3448
  console.log(colors8.yellow("Schema file already exists. Skipping generation of sample."));
3424
3449
  }
@@ -3429,8 +3454,8 @@ async function run6(projectPath) {
3429
3454
  __name(run6, "run");
3430
3455
 
3431
3456
  // src/actions/migrate.ts
3432
- import fs8 from "fs";
3433
- import path7 from "path";
3457
+ import fs7 from "fs";
3458
+ import path8 from "path";
3434
3459
 
3435
3460
  // src/actions/seed.ts
3436
3461
  import colors9 from "colors";
@@ -3463,7 +3488,7 @@ __name(run7, "run");
3463
3488
  async function run8(command, options) {
3464
3489
  const schemaFile = getSchemaFile(options.schema);
3465
3490
  await requireDataSourceUrl(schemaFile);
3466
- const prismaSchemaDir = options.migrations ? path7.dirname(options.migrations) : void 0;
3491
+ const prismaSchemaDir = options.migrations ? path8.dirname(options.migrations) : void 0;
3467
3492
  const prismaSchemaFile = await generateTempPrismaSchema(schemaFile, prismaSchemaDir);
3468
3493
  try {
3469
3494
  switch (command) {
@@ -3484,8 +3509,8 @@ async function run8(command, options) {
3484
3509
  break;
3485
3510
  }
3486
3511
  } finally {
3487
- if (fs8.existsSync(prismaSchemaFile)) {
3488
- fs8.unlinkSync(prismaSchemaFile);
3512
+ if (fs7.existsSync(prismaSchemaFile)) {
3513
+ fs7.unlinkSync(prismaSchemaFile);
3489
3514
  }
3490
3515
  }
3491
3516
  }
@@ -3586,20 +3611,20 @@ import colors11 from "colors";
3586
3611
  import cors from "cors";
3587
3612
  import express from "express";
3588
3613
  import { createJiti as createJiti2 } from "jiti";
3589
- import path9 from "path";
3614
+ import path10 from "path";
3590
3615
 
3591
3616
  // src/utils/version-utils.ts
3592
3617
  import colors10 from "colors";
3593
- import fs9 from "fs";
3594
- import path8 from "path";
3618
+ import fs8 from "fs";
3619
+ import path9 from "path";
3595
3620
  import { fileURLToPath as fileURLToPath2 } from "url";
3596
3621
  import semver2 from "semver";
3597
3622
  var CHECK_VERSION_TIMEOUT = 2e3;
3598
3623
  var VERSION_CHECK_TAG = "latest";
3599
3624
  function getVersion() {
3600
3625
  try {
3601
- const _dirname = typeof __dirname !== "undefined" ? __dirname : path8.dirname(fileURLToPath2(import.meta.url));
3602
- return JSON.parse(fs9.readFileSync(path8.join(_dirname, "../package.json"), "utf8")).version;
3626
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : path9.dirname(fileURLToPath2(import.meta.url));
3627
+ return JSON.parse(fs8.readFileSync(path9.join(_dirname, "../package.json"), "utf8")).version;
3603
3628
  } catch {
3604
3629
  return void 0;
3605
3630
  }
@@ -3646,8 +3671,8 @@ async function run9(options) {
3646
3671
  const schemaFile = getSchemaFile(options.schema);
3647
3672
  console.log(colors11.gray(`Loading ZModel schema from: ${schemaFile}`));
3648
3673
  let outputPath = getOutputPath(options, schemaFile);
3649
- if (!path9.isAbsolute(outputPath)) {
3650
- outputPath = path9.resolve(process.cwd(), outputPath);
3674
+ if (!path10.isAbsolute(outputPath)) {
3675
+ outputPath = path10.resolve(process.cwd(), outputPath);
3651
3676
  }
3652
3677
  const model = await loadSchemaDocument(schemaFile);
3653
3678
  const dataSource = model.declarations.find(isDataSource2);
@@ -3663,18 +3688,18 @@ async function run9(options) {
3663
3688
  const dialect = await createDialect(provider, databaseUrl, outputPath);
3664
3689
  const fileUrl = typeof __filename !== "undefined" ? __filename : import.meta.url;
3665
3690
  const jiti = createJiti2(fileUrl);
3666
- const schemaModule = await jiti.import(path9.join(outputPath, "schema"));
3691
+ const schemaModule = await jiti.import(path10.join(outputPath, "schema"));
3667
3692
  const schema = schemaModule.schema;
3668
3693
  const omit = {};
3669
3694
  for (const [modelName, modelDef] of Object.entries(schema.models)) {
3670
- const computedFields = {};
3695
+ const omitFields = {};
3671
3696
  for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) {
3672
- if (fieldDef.computed === true) {
3673
- computedFields[fieldName] = true;
3697
+ if (fieldDef.computed === true || fieldDef.type === "Unsupported") {
3698
+ omitFields[fieldName] = true;
3674
3699
  }
3675
3700
  }
3676
- if (Object.keys(computedFields).length > 0) {
3677
- omit[modelName] = computedFields;
3701
+ if (Object.keys(omitFields).length > 0) {
3702
+ omit[modelName] = omitFields;
3678
3703
  }
3679
3704
  }
3680
3705
  const db = new ZenStackClient(schema, {
@@ -3734,8 +3759,8 @@ async function createDialect(provider, databaseUrl, outputPath) {
3734
3759
  let resolvedUrl = databaseUrl.trim();
3735
3760
  if (resolvedUrl.startsWith("file:")) {
3736
3761
  const filePath = resolvedUrl.substring("file:".length);
3737
- if (!path9.isAbsolute(filePath)) {
3738
- resolvedUrl = path9.join(outputPath, filePath);
3762
+ if (!path10.isAbsolute(filePath)) {
3763
+ resolvedUrl = path10.join(outputPath, filePath);
3739
3764
  }
3740
3765
  }
3741
3766
  console.log(colors11.gray(`Connecting to SQLite database at: ${resolvedUrl}`));
@@ -3833,7 +3858,7 @@ __name(startServer, "startServer");
3833
3858
  // src/telemetry.ts
3834
3859
  import { init } from "mixpanel";
3835
3860
  import { randomUUID as randomUUID2 } from "crypto";
3836
- import fs13 from "fs";
3861
+ import fs12 from "fs";
3837
3862
  import * as os2 from "os";
3838
3863
 
3839
3864
  // src/constants.ts
@@ -3844,14 +3869,14 @@ import { env } from "process";
3844
3869
  var isInCi = env["CI"] !== "0" && env["CI"] !== "false" && ("CI" in env || "CONTINUOUS_INTEGRATION" in env || Object.keys(env).some((key) => key.startsWith("CI_")));
3845
3870
 
3846
3871
  // src/utils/is-container.ts
3847
- import fs11 from "fs";
3872
+ import fs10 from "fs";
3848
3873
 
3849
3874
  // src/utils/is-docker.ts
3850
- import fs10 from "fs";
3875
+ import fs9 from "fs";
3851
3876
  var isDockerCached;
3852
3877
  function hasDockerEnv() {
3853
3878
  try {
3854
- fs10.statSync("/.dockerenv");
3879
+ fs9.statSync("/.dockerenv");
3855
3880
  return true;
3856
3881
  } catch {
3857
3882
  return false;
@@ -3860,7 +3885,7 @@ function hasDockerEnv() {
3860
3885
  __name(hasDockerEnv, "hasDockerEnv");
3861
3886
  function hasDockerCGroup() {
3862
3887
  try {
3863
- return fs10.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
3888
+ return fs9.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
3864
3889
  } catch {
3865
3890
  return false;
3866
3891
  }
@@ -3878,7 +3903,7 @@ __name(isDocker, "isDocker");
3878
3903
  var cachedResult;
3879
3904
  var hasContainerEnv = /* @__PURE__ */ __name(() => {
3880
3905
  try {
3881
- fs11.statSync("/run/.containerenv");
3906
+ fs10.statSync("/run/.containerenv");
3882
3907
  return true;
3883
3908
  } catch {
3884
3909
  return false;
@@ -3895,7 +3920,7 @@ __name(isInContainer, "isInContainer");
3895
3920
  // src/utils/is-wsl.ts
3896
3921
  import process2 from "process";
3897
3922
  import os from "os";
3898
- import fs12 from "fs";
3923
+ import fs11 from "fs";
3899
3924
  var isWsl = /* @__PURE__ */ __name(() => {
3900
3925
  if (process2.platform !== "linux") {
3901
3926
  return false;
@@ -3904,7 +3929,7 @@ var isWsl = /* @__PURE__ */ __name(() => {
3904
3929
  return true;
3905
3930
  }
3906
3931
  try {
3907
- return fs12.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
3932
+ return fs11.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
3908
3933
  } catch {
3909
3934
  return false;
3910
3935
  }
@@ -4060,7 +4085,7 @@ var Telemetry = class {
4060
4085
  try {
4061
4086
  const packageJsonPath = import.meta.resolve("prisma/package.json");
4062
4087
  const packageJsonUrl = new URL(packageJsonPath);
4063
- const packageJson = JSON.parse(fs13.readFileSync(packageJsonUrl, "utf8"));
4088
+ const packageJson = JSON.parse(fs12.readFileSync(packageJsonUrl, "utf8"));
4064
4089
  return packageJson.version;
4065
4090
  } catch {
4066
4091
  return void 0;