@aeriajs/compiler 0.0.28 → 0.0.30

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
@@ -34,6 +34,7 @@ export type FormLayoutNode = NodeBase<'formLayout'> & FormLayout<Description> &
34
34
  field: FormLayoutField<Description>;
35
35
  };
36
36
  };
37
+ terms?: [string, symbol][];
37
38
  };
38
39
  };
39
40
  export type PropertyNode = NodeBase<'property'> & {
@@ -68,6 +69,7 @@ export type CollectionNode = NodeBase<'collection'> & {
68
69
  presets?: DescriptionPreset[];
69
70
  form?: string[];
70
71
  table?: string[];
72
+ tableMeta?: string[];
71
73
  filters?: string[];
72
74
  search?: SearchOptions<any>;
73
75
  layout?: LayoutNode;
package/dist/lexer.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type Token } from './token.js';
2
2
  import { Diagnostic } from './diagnostic.js';
3
- export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "formLayout", "functions", "icon", "indexes", "individualActions", "layout", "owned", "presets", "properties", "required", "search", "table"];
3
+ export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "formLayout", "functions", "icon", "indexes", "individualActions", "layout", "owned", "presets", "properties", "required", "search", "table", "tableMeta"];
4
4
  export declare const COLLECTION_ACTIONS_KEYWORDS: readonly ["ask", "button", "clearItem", "effect", "event", "fetchItem", "function", "icon", "label", "params", "query", "requires", "roles", "route", "selection", "setItem", "translate"];
5
5
  export declare const COLLECTION_SEARCH_KEYWORDS: readonly ["indexes", "placeholder", "exactMatches"];
6
6
  export declare const COLLECTION_LAYOUT_KEYWORDS: readonly ["name", "options"];
package/dist/lexer.js CHANGED
@@ -20,6 +20,7 @@ exports.COLLECTION_KEYWORDS = [
20
20
  'required',
21
21
  'search',
22
22
  'table',
23
+ 'tableMeta',
23
24
  ];
24
25
  exports.COLLECTION_ACTIONS_KEYWORDS = [
25
26
  'ask',
@@ -292,6 +293,7 @@ const tokenize = function (rawInput) {
292
293
  case 'information':
293
294
  case 'form':
294
295
  case 'table':
296
+ case 'tableMeta':
295
297
  case 'indexes':
296
298
  case 'filters':
297
299
  case 'writable':
package/dist/lexer.mjs CHANGED
@@ -17,7 +17,8 @@ export const COLLECTION_KEYWORDS = [
17
17
  "properties",
18
18
  "required",
19
19
  "search",
20
- "table"
20
+ "table",
21
+ "tableMeta"
21
22
  ];
22
23
  export const COLLECTION_ACTIONS_KEYWORDS = [
23
24
  "ask",
@@ -295,6 +296,7 @@ export const tokenize = function(rawInput) {
295
296
  case "information":
296
297
  case "form":
297
298
  case "table":
299
+ case "tableMeta":
298
300
  case "indexes":
299
301
  case "filters":
300
302
  case "writable":
package/dist/parser.js CHANGED
@@ -256,6 +256,10 @@ const parse = (tokens) => {
256
256
  property[attributeName] = value;
257
257
  return;
258
258
  }
259
+ case 'translate': {
260
+ property[attributeName] = consumeBoolean();
261
+ return;
262
+ }
259
263
  }
260
264
  if ('$ref' in property) {
261
265
  switch (attributeName) {
@@ -718,6 +722,7 @@ const parse = (tokens) => {
718
722
  case 'indexes':
719
723
  case 'form':
720
724
  case 'table':
725
+ case 'tableMeta':
721
726
  case 'filters': {
722
727
  const { value, symbols } = parseArrayBlock();
723
728
  node[keyword] = value;
@@ -1088,7 +1093,9 @@ const parse = (tokens) => {
1088
1093
  const { value: keyword, location: keywordLocation } = consume(token_js_1.TokenType.Keyword, lexer.COLLECTION_FORM_LAYOUT_KEYWORDS);
1089
1094
  switch (keyword) {
1090
1095
  case 'if': {
1091
- fields[identifier].if = parseCondition();
1096
+ const ifTerms = [];
1097
+ fields[identifier].if = parseCondition(ifTerms);
1098
+ node[AST.LOCATION_SYMBOL].terms = ifTerms;
1092
1099
  break;
1093
1100
  }
1094
1101
  case 'span':
@@ -1123,13 +1130,13 @@ const parse = (tokens) => {
1123
1130
  consume(token_js_1.TokenType.RightBracket);
1124
1131
  return node;
1125
1132
  };
1126
- const parseCondition = () => {
1133
+ const parseCondition = (symbols = []) => {
1127
1134
  if (match(token_js_1.TokenType.LeftParens)) {
1128
1135
  consume(token_js_1.TokenType.LeftParens);
1129
1136
  let operatorType, newOp = operatorType;
1130
1137
  const conditions = [];
1131
1138
  while (!match(token_js_1.TokenType.RightParens)) {
1132
- conditions.push(parseCondition());
1139
+ conditions.push(parseCondition(symbols));
1133
1140
  if (match(token_js_1.TokenType.RightParens)) {
1134
1141
  break;
1135
1142
  }
@@ -1170,20 +1177,26 @@ const parse = (tokens) => {
1170
1177
  if (match(token_js_1.TokenType.Operator, '!')) {
1171
1178
  consume(token_js_1.TokenType.Operator);
1172
1179
  return {
1173
- not: parseCondition(),
1180
+ not: parseCondition(symbols),
1174
1181
  };
1175
1182
  }
1176
- const { value: term1 } = consume(token_js_1.TokenType.Identifier);
1183
+ const { value: term1, location: term1Location } = consume(token_js_1.TokenType.Identifier);
1184
+ const term1Symbol = Symbol();
1185
+ exports.locationMap.set(term1Symbol, term1Location);
1186
+ symbols.push([
1187
+ term1,
1188
+ term1Symbol,
1189
+ ]);
1177
1190
  if (!match(token_js_1.TokenType.Operator, lexer.FINAL_OPERATORS)) {
1178
1191
  return {
1179
1192
  operator: 'truthy',
1180
- term1: term1,
1193
+ term1,
1181
1194
  };
1182
1195
  }
1183
1196
  const { value: operatorSymbol, location } = consume(token_js_1.TokenType.Operator);
1184
1197
  let term2;
1185
1198
  if (match(token_js_1.TokenType.LeftParens)) {
1186
- term2 = parseCondition();
1199
+ term2 = parseCondition(symbols);
1187
1200
  }
1188
1201
  else {
1189
1202
  term2 = current().value;
package/dist/parser.mjs CHANGED
@@ -215,6 +215,10 @@ export const parse = (tokens) => {
215
215
  property[attributeName] = value;
216
216
  return;
217
217
  }
218
+ case "translate": {
219
+ property[attributeName] = consumeBoolean();
220
+ return;
221
+ }
218
222
  }
219
223
  if ("$ref" in property) {
220
224
  switch (attributeName) {
@@ -663,6 +667,7 @@ export const parse = (tokens) => {
663
667
  case "indexes":
664
668
  case "form":
665
669
  case "table":
670
+ case "tableMeta":
666
671
  case "filters": {
667
672
  const { value, symbols } = parseArrayBlock();
668
673
  node[keyword] = value;
@@ -1027,7 +1032,9 @@ export const parse = (tokens) => {
1027
1032
  const { value: keyword2, location: keywordLocation2 } = consume(TokenType.Keyword, lexer.COLLECTION_FORM_LAYOUT_KEYWORDS);
1028
1033
  switch (keyword2) {
1029
1034
  case "if": {
1030
- fields[identifier].if = parseCondition();
1035
+ const ifTerms = [];
1036
+ fields[identifier].if = parseCondition(ifTerms);
1037
+ node[AST.LOCATION_SYMBOL].terms = ifTerms;
1031
1038
  break;
1032
1039
  }
1033
1040
  case "span":
@@ -1060,13 +1067,13 @@ export const parse = (tokens) => {
1060
1067
  consume(TokenType.RightBracket);
1061
1068
  return node;
1062
1069
  };
1063
- const parseCondition = () => {
1070
+ const parseCondition = (symbols = []) => {
1064
1071
  if (match(TokenType.LeftParens)) {
1065
1072
  consume(TokenType.LeftParens);
1066
1073
  let operatorType, newOp = operatorType;
1067
1074
  const conditions = [];
1068
1075
  while (!match(TokenType.RightParens)) {
1069
- conditions.push(parseCondition());
1076
+ conditions.push(parseCondition(symbols));
1070
1077
  if (match(TokenType.RightParens)) {
1071
1078
  break;
1072
1079
  }
@@ -1107,10 +1114,16 @@ export const parse = (tokens) => {
1107
1114
  if (match(TokenType.Operator, "!")) {
1108
1115
  consume(TokenType.Operator);
1109
1116
  return {
1110
- not: parseCondition()
1117
+ not: parseCondition(symbols)
1111
1118
  };
1112
1119
  }
1113
- const { value: term1 } = consume(TokenType.Identifier);
1120
+ const { value: term1, location: term1Location } = consume(TokenType.Identifier);
1121
+ const term1Symbol = Symbol();
1122
+ locationMap.set(term1Symbol, term1Location);
1123
+ symbols.push([
1124
+ term1,
1125
+ term1Symbol
1126
+ ]);
1114
1127
  if (!match(TokenType.Operator, lexer.FINAL_OPERATORS)) {
1115
1128
  return {
1116
1129
  operator: "truthy",
@@ -1120,7 +1133,7 @@ export const parse = (tokens) => {
1120
1133
  const { value: operatorSymbol, location } = consume(TokenType.Operator);
1121
1134
  let term2;
1122
1135
  if (match(TokenType.LeftParens)) {
1123
- term2 = parseCondition();
1136
+ term2 = parseCondition(symbols);
1124
1137
  } else {
1125
1138
  term2 = current().value;
1126
1139
  advance();
package/dist/semantic.js CHANGED
@@ -169,6 +169,14 @@ const analyze = async (ast, options, errors = []) => {
169
169
  }
170
170
  }
171
171
  }
172
+ if (node.formLayout[AST.LOCATION_SYMBOL].terms) {
173
+ for (const [name, symbol] of node.formLayout[AST.LOCATION_SYMBOL].terms) {
174
+ if (!(name in node.properties)) {
175
+ const location = parser_js_1.locationMap.get(symbol);
176
+ errors.push(new diagnostic_js_1.Diagnostic(`invalid left operand "${name}"`, location));
177
+ }
178
+ }
179
+ }
172
180
  }
173
181
  }
174
182
  for (const node of ast.contracts) {
package/dist/semantic.mjs CHANGED
@@ -131,6 +131,14 @@ export const analyze = async (ast, options, errors = []) => {
131
131
  }
132
132
  }
133
133
  }
134
+ if (node.formLayout[AST.LOCATION_SYMBOL].terms) {
135
+ for (const [name, symbol] of node.formLayout[AST.LOCATION_SYMBOL].terms) {
136
+ if (!(name in node.properties)) {
137
+ const location = locationMap.get(symbol);
138
+ errors.push(new Diagnostic(`invalid left operand "${name}"`, location));
139
+ }
140
+ }
141
+ }
134
142
  }
135
143
  }
136
144
  for (const node of ast.contracts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/compiler",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",