@zenstackhq/language 3.6.4 → 3.7.0
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 +26 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +25 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{utils-BB6L7ug2.mjs → utils-CCU55PfR.mjs} +14 -3
- package/dist/utils-CCU55PfR.mjs.map +1 -0
- package/dist/{utils-CfXGZkv7.cjs → utils-b3dJKmYr.cjs} +18 -1
- package/dist/utils-b3dJKmYr.cjs.map +1 -0
- package/dist/utils.cjs +2 -1
- package/dist/utils.d.cts +6 -1
- package/dist/utils.d.mts +6 -1
- package/dist/utils.mjs +2 -2
- package/package.json +6 -6
- package/res/stdlib.zmodel +15 -1
- package/dist/utils-BB6L7ug2.mjs.map +0 -1
- package/dist/utils-CfXGZkv7.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_ast = require("./ast-Clidp86c.cjs");
|
|
3
3
|
const require_ast$1 = require("./ast.cjs");
|
|
4
|
-
const require_utils = require("./utils-
|
|
4
|
+
const require_utils = require("./utils-b3dJKmYr.cjs");
|
|
5
5
|
let _zenstackhq_common_helpers = require("@zenstackhq/common-helpers");
|
|
6
6
|
let langium = require("langium");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
@@ -4317,6 +4317,18 @@ var AttributeApplicationValidator = class {
|
|
|
4317
4317
|
});
|
|
4318
4318
|
} else accept("error", `Expected an array of field references`, { node: fields });
|
|
4319
4319
|
}
|
|
4320
|
+
_checkFuzzy(attr, accept) {
|
|
4321
|
+
const zmodel = langium.AstUtils.getContainerOfType(attr, require_ast.isModel);
|
|
4322
|
+
if (!zmodel) return;
|
|
4323
|
+
const provider = require_utils.getDataSourceProvider(zmodel);
|
|
4324
|
+
if (provider && provider !== "postgresql") accept("error", `\`@fuzzy\` is only supported for the \`postgresql\` provider`, { node: attr });
|
|
4325
|
+
}
|
|
4326
|
+
_checkFullText(attr, accept) {
|
|
4327
|
+
const zmodel = langium.AstUtils.getContainerOfType(attr, require_ast.isModel);
|
|
4328
|
+
if (!zmodel) return;
|
|
4329
|
+
const provider = require_utils.getDataSourceProvider(zmodel);
|
|
4330
|
+
if (provider && provider !== "postgresql") accept("error", `\`@fullText\` is only supported for the \`postgresql\` provider`, { node: attr });
|
|
4331
|
+
}
|
|
4320
4332
|
_checkSchema(attr, accept) {
|
|
4321
4333
|
const schemaName = require_utils.getStringLiteral(attr.args[0]?.value);
|
|
4322
4334
|
(0, _zenstackhq_common_helpers.invariant)(schemaName, `@@schema expects a string literal`);
|
|
@@ -4370,6 +4382,18 @@ __decorate([
|
|
|
4370
4382
|
__decorateMetadata("design:paramtypes", [Object, Object]),
|
|
4371
4383
|
__decorateMetadata("design:returntype", void 0)
|
|
4372
4384
|
], AttributeApplicationValidator.prototype, "_checkConstraint", null);
|
|
4385
|
+
__decorate([
|
|
4386
|
+
check("@fuzzy"),
|
|
4387
|
+
__decorateMetadata("design:type", Function),
|
|
4388
|
+
__decorateMetadata("design:paramtypes", [Object, Object]),
|
|
4389
|
+
__decorateMetadata("design:returntype", void 0)
|
|
4390
|
+
], AttributeApplicationValidator.prototype, "_checkFuzzy", null);
|
|
4391
|
+
__decorate([
|
|
4392
|
+
check("@fullText"),
|
|
4393
|
+
__decorateMetadata("design:type", Function),
|
|
4394
|
+
__decorateMetadata("design:paramtypes", [Object, Object]),
|
|
4395
|
+
__decorateMetadata("design:returntype", void 0)
|
|
4396
|
+
], AttributeApplicationValidator.prototype, "_checkFullText", null);
|
|
4373
4397
|
__decorate([
|
|
4374
4398
|
check("@@schema"),
|
|
4375
4399
|
__decorateMetadata("design:type", Function),
|
|
@@ -6884,7 +6908,7 @@ function validationAfterImportMerge(model) {
|
|
|
6884
6908
|
if (dataSources.length === 0) errors.push("Validation error: schema must have a datasource declaration");
|
|
6885
6909
|
else if (dataSources.length > 1) errors.push("Validation error: multiple datasource declarations are not allowed");
|
|
6886
6910
|
if (require_utils.getDataModelAndTypeDefs(model, true).filter((d) => require_utils.hasAttribute(d, "@@auth")).length > 1) errors.push("Validation error: Multiple `@@auth` declarations are not allowed");
|
|
6887
|
-
const provider = getDataSourceProvider(model);
|
|
6911
|
+
const provider = require_utils.getDataSourceProvider(model);
|
|
6888
6912
|
(0, _zenstackhq_common_helpers.invariant)(provider !== void 0, "Datasource provider should be defined at this point");
|
|
6889
6913
|
for (const decl of model.declarations.filter(require_ast.isDataModel)) {
|
|
6890
6914
|
const fields = require_utils.getAllFields(decl, true);
|
|
@@ -6912,13 +6936,6 @@ async function formatDocument(content) {
|
|
|
6912
6936
|
});
|
|
6913
6937
|
return langium.TextDocument.applyEdits(document.textDocument, edits);
|
|
6914
6938
|
}
|
|
6915
|
-
function getDataSourceProvider(model) {
|
|
6916
|
-
const dataSource = model.declarations.find(require_ast.isDataSource);
|
|
6917
|
-
if (!dataSource) return;
|
|
6918
|
-
const provider = dataSource?.fields.find((f) => f.name === "provider");
|
|
6919
|
-
if (!provider) return;
|
|
6920
|
-
return require_utils.getLiteral(provider.value);
|
|
6921
|
-
}
|
|
6922
6939
|
//#endregion
|
|
6923
6940
|
exports.ZModelCodeGenerator = ZModelCodeGenerator;
|
|
6924
6941
|
exports.ZModelLanguageMetaData = ZModelLanguageMetaData;
|