@aeriajs/compiler 0.0.35 → 0.0.37

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 CHANGED
@@ -48,6 +48,7 @@ export type PropertyNode = NodeBase<'property'> & {
48
48
  properties: unknown;
49
49
  }>>]?: symbol[];
50
50
  };
51
+ contraintTerms?: [string, symbol][];
51
52
  };
52
53
  };
53
54
  nestedProperties?: Record<string, PropertyNode>;
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)) {
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)) {
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/compiler",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -21,8 +21,8 @@
21
21
  "dist"
22
22
  ],
23
23
  "peerDependencies": {
24
- "@aeriajs/common": "^0.0.143",
25
- "@aeriajs/types": "^0.0.125"
24
+ "@aeriajs/common": "^0.0.144",
25
+ "@aeriajs/types": "^0.0.126"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@aeriajs/common": "link:../common",