@aeriajs/compiler 0.0.36 → 0.0.38
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/ast.d.ts +1 -0
- package/dist/parser.js +6 -0
- package/dist/parser.mjs +6 -0
- package/dist/semantic.js +9 -1
- package/dist/semantic.mjs +9 -1
- package/package.json +1 -1
package/dist/ast.d.ts
CHANGED
package/dist/parser.js
CHANGED
|
@@ -285,6 +285,12 @@ const parse = (tokens) => {
|
|
|
285
285
|
property[attributeName] = value;
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
+
case 'constraints': {
|
|
289
|
+
const constraintTerms = [];
|
|
290
|
+
property[attributeName] = parseCondition(constraintTerms);
|
|
291
|
+
property[AST.LOCATION_SYMBOL].contraintTerms = constraintTerms;
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
288
294
|
}
|
|
289
295
|
if (isFileProperty(property)) {
|
|
290
296
|
switch (attributeName) {
|
package/dist/parser.mjs
CHANGED
|
@@ -245,6 +245,12 @@ export const parse = (tokens) => {
|
|
|
245
245
|
property[attributeName] = value;
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
+
case "constraints": {
|
|
249
|
+
const constraintTerms = [];
|
|
250
|
+
property[attributeName] = parseCondition(constraintTerms);
|
|
251
|
+
property[AST.LOCATION_SYMBOL].contraintTerms = constraintTerms;
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
248
254
|
}
|
|
249
255
|
if (isFileProperty(property)) {
|
|
250
256
|
switch (attributeName) {
|
package/dist/semantic.js
CHANGED
|
@@ -38,7 +38,7 @@ const common_1 = require("@aeriajs/common");
|
|
|
38
38
|
const parser_js_1 = require("./parser.js");
|
|
39
39
|
const diagnostic_js_1 = require("./diagnostic.js");
|
|
40
40
|
const AST = __importStar(require("./ast.js"));
|
|
41
|
-
const collectionHasProperty = async (collection, propName, options) => {
|
|
41
|
+
const collectionHasProperty = async (collection, propName, options = {}) => {
|
|
42
42
|
let hasProperty = propName in collection.properties;
|
|
43
43
|
if (!hasProperty) {
|
|
44
44
|
if (collection.extends) {
|
|
@@ -122,6 +122,14 @@ const analyze = async (ast, options, errors = []) => {
|
|
|
122
122
|
await checkCollectionForeignProperties(foreignCollection, node.property, 'indexes');
|
|
123
123
|
await checkCollectionForeignProperties(foreignCollection, node.property, 'populate');
|
|
124
124
|
await checkCollectionForeignProperties(foreignCollection, node.property, 'form');
|
|
125
|
+
if (node.property.constraints) {
|
|
126
|
+
for (const [name, symbol] of node.property[AST.LOCATION_SYMBOL].contraintTerms) {
|
|
127
|
+
if (!await collectionHasProperty(foreignCollection, name, options)) {
|
|
128
|
+
const location = parser_js_1.locationMap.get(symbol);
|
|
129
|
+
errors.push(new diagnostic_js_1.Diagnostic(`left operand "${name}" does not exist on collection "${foreignCollection.name}"`, location));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
125
133
|
}
|
|
126
134
|
else if ('items' in node.property) {
|
|
127
135
|
await recurseProperty({
|
package/dist/semantic.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { isValidCollection } from "@aeriajs/common";
|
|
|
3
3
|
import { locationMap } from "./parser.mjs";
|
|
4
4
|
import { Diagnostic } from "./diagnostic.mjs";
|
|
5
5
|
import * as AST from "./ast.mjs";
|
|
6
|
-
const collectionHasProperty = async (collection, propName, options) => {
|
|
6
|
+
const collectionHasProperty = async (collection, propName, options = {}) => {
|
|
7
7
|
let hasProperty = propName in collection.properties;
|
|
8
8
|
if (!hasProperty) {
|
|
9
9
|
if (collection.extends) {
|
|
@@ -86,6 +86,14 @@ export const analyze = async (ast, options, errors = []) => {
|
|
|
86
86
|
await checkCollectionForeignProperties(foreignCollection, node.property, "indexes");
|
|
87
87
|
await checkCollectionForeignProperties(foreignCollection, node.property, "populate");
|
|
88
88
|
await checkCollectionForeignProperties(foreignCollection, node.property, "form");
|
|
89
|
+
if (node.property.constraints) {
|
|
90
|
+
for (const [name, symbol] of node.property[AST.LOCATION_SYMBOL].contraintTerms) {
|
|
91
|
+
if (!await collectionHasProperty(foreignCollection, name, options)) {
|
|
92
|
+
const location = locationMap.get(symbol);
|
|
93
|
+
errors.push(new Diagnostic(`left operand "${name}" does not exist on collection "${foreignCollection.name}"`, location));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
89
97
|
} else if ("items" in node.property) {
|
|
90
98
|
await recurseProperty({
|
|
91
99
|
kind: "property",
|