@zenstackhq/language 3.0.0-alpha.16 → 3.0.0-alpha.17

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.cjs CHANGED
@@ -6407,26 +6407,15 @@ var DataSourceValidator = class {
6407
6407
  }
6408
6408
  }
6409
6409
  validateUrl(ds, accept) {
6410
- const url = ds.fields.find((f) => f.name === "url");
6411
- if (!url) {
6412
- accept("error", 'datasource must include a "url" field', {
6413
- node: ds
6414
- });
6410
+ const urlField = ds.fields.find((f) => f.name === "url");
6411
+ if (!urlField) {
6412
+ return;
6415
6413
  }
6416
- for (const fieldName of [
6417
- "url",
6418
- "shadowDatabaseUrl"
6419
- ]) {
6420
- const field = ds.fields.find((f) => f.name === fieldName);
6421
- if (!field) {
6422
- continue;
6423
- }
6424
- const value = getStringLiteral(field.value);
6425
- if (!value && !(isInvocationExpr(field.value) && field.value.function.ref?.name === "env")) {
6426
- accept("error", `"${fieldName}" must be set to a string literal or an invocation of "env" function`, {
6427
- node: field.value
6428
- });
6429
- }
6414
+ const value = getStringLiteral(urlField.value);
6415
+ if (!value && !(isInvocationExpr(urlField.value) && urlField.value.function.ref?.name === "env")) {
6416
+ accept("error", `"${urlField.name}" must be set to a string literal or an invocation of "env" function`, {
6417
+ node: urlField.value
6418
+ });
6430
6419
  }
6431
6420
  }
6432
6421
  validateRelationMode(ds, accept) {
@@ -7837,8 +7826,12 @@ __name(linkContentToContainer, "linkContentToContainer");
7837
7826
  function validationAfterImportMerge(model) {
7838
7827
  const errors = [];
7839
7828
  const dataSources = model.declarations.filter((d) => isDataSource(d));
7840
- if (dataSources.length > 1) {
7841
- errors.push("Validation error: Multiple datasource declarations are not allowed");
7829
+ if (dataSources.length === 0) {
7830
+ errors.push("Validation error: schema must have a datasource declaration");
7831
+ } else {
7832
+ if (dataSources.length > 1) {
7833
+ errors.push("Validation error: multiple datasource declarations are not allowed");
7834
+ }
7842
7835
  }
7843
7836
  const decls = getDataModelAndTypeDefs(model, true);
7844
7837
  const authDecls = decls.filter((d) => hasAttribute(d, "@@auth"));