@aeriajs/compiler 0.0.47 → 0.0.49

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
@@ -74,7 +74,7 @@ export type CollectionNode = NodeBase<'collection'> & {
74
74
  table?: readonly string[];
75
75
  tableMeta?: readonly string[];
76
76
  filters?: readonly string[];
77
- search?: SearchOptions<any>;
77
+ search?: SearchOptions;
78
78
  layout?: LayoutNode;
79
79
  formLayout?: FormLayoutNode;
80
80
  [LOCATION_SYMBOL]: {
@@ -83,6 +83,7 @@ export type CollectionNode = NodeBase<'collection'> & {
83
83
  };
84
84
  required?: symbol[];
85
85
  requiredTerms?: readonly [string, symbol][];
86
+ searchIndexes?: symbol[];
86
87
  };
87
88
  };
88
89
  export type ContractNode = NodeBase<'contract'> & {
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", "middlewares", "owned", "presets", "properties", "required", "search", "table", "tableMeta"];
3
+ export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "formLayout", "functions", "icon", "indexes", "individualActions", "layout", "middlewares", "owned", "presets", "properties", "required", "search", "table", "tableMeta", "writable"];
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
@@ -22,6 +22,7 @@ exports.COLLECTION_KEYWORDS = [
22
22
  'search',
23
23
  'table',
24
24
  'tableMeta',
25
+ 'writable',
25
26
  ];
26
27
  exports.COLLECTION_ACTIONS_KEYWORDS = [
27
28
  'ask',
package/dist/lexer.mjs CHANGED
@@ -19,7 +19,8 @@ export const COLLECTION_KEYWORDS = [
19
19
  "required",
20
20
  "search",
21
21
  "table",
22
- "tableMeta"
22
+ "tableMeta",
23
+ "writable"
23
24
  ];
24
25
  export const COLLECTION_ACTIONS_KEYWORDS = [
25
26
  "ask",
package/dist/parser.js CHANGED
@@ -473,23 +473,20 @@ const parse = (tokens) => {
473
473
  },
474
474
  };
475
475
  while (!match(token_js_1.TokenType.RightBracket)) {
476
- const { value: keyword, location } = current();
476
+ const { value: keyword, location } = consume(token_js_1.TokenType.Keyword, lexer.COLLECTION_KEYWORDS);
477
477
  switch (keyword) {
478
478
  case 'writable':
479
479
  case 'required': {
480
- consume(token_js_1.TokenType.Keyword);
481
480
  const { value, symbols } = parseArrayBlock();
482
481
  property[keyword] = value;
483
482
  property[AST.LOCATION_SYMBOL].arrays[keyword] = symbols;
484
483
  break;
485
484
  }
486
485
  case 'properties': {
487
- consume(token_js_1.TokenType.Keyword);
488
486
  nestedProperties = parsePropertiesBlock(options);
489
487
  break;
490
488
  }
491
489
  case 'additionalProperties': {
492
- consume(token_js_1.TokenType.Keyword);
493
490
  if (match(token_js_1.TokenType.Boolean)) {
494
491
  nestedAdditionalProperties = consume(token_js_1.TokenType.Boolean).value;
495
492
  }
@@ -761,7 +758,9 @@ const parse = (tokens) => {
761
758
  break;
762
759
  }
763
760
  case 'search': {
764
- node[keyword] = parseSearchBlock();
761
+ const { options, indexesSymbols } = parseSearchBlock();
762
+ node[keyword] = options;
763
+ node[AST.LOCATION_SYMBOL].searchIndexes = indexesSymbols;
765
764
  break;
766
765
  }
767
766
  case 'layout': {
@@ -1003,9 +1002,16 @@ const parse = (tokens) => {
1003
1002
  const parseSearchBlock = () => {
1004
1003
  const searchSlots = {};
1005
1004
  const { location } = consume(token_js_1.TokenType.LeftBracket);
1005
+ let indexesSymbols;
1006
1006
  while (!match(token_js_1.TokenType.RightBracket)) {
1007
1007
  const { value: keyword } = consume(token_js_1.TokenType.Keyword, lexer.COLLECTION_SEARCH_KEYWORDS);
1008
1008
  switch (keyword) {
1009
+ case 'indexes': {
1010
+ const { value, symbols } = parseArrayBlock();
1011
+ searchSlots[keyword] = value;
1012
+ indexesSymbols = symbols;
1013
+ break;
1014
+ }
1009
1015
  case 'placeholder': {
1010
1016
  const { value } = consume(token_js_1.TokenType.QuotedString);
1011
1017
  searchSlots[keyword] = value;
@@ -1016,11 +1022,6 @@ const parse = (tokens) => {
1016
1022
  searchSlots[keyword] = value;
1017
1023
  break;
1018
1024
  }
1019
- case 'indexes': {
1020
- const { value } = parseArrayBlock();
1021
- searchSlots[keyword] = value;
1022
- break;
1023
- }
1024
1025
  }
1025
1026
  }
1026
1027
  const { indexes } = searchSlots;
@@ -1028,10 +1029,14 @@ const parse = (tokens) => {
1028
1029
  throw new diagnostic_js_1.Diagnostic('"indexes" option is required', location);
1029
1030
  }
1030
1031
  consume(token_js_1.TokenType.RightBracket);
1031
- return {
1032
+ const options = {
1032
1033
  ...searchSlots,
1033
1034
  indexes,
1034
1035
  };
1036
+ return {
1037
+ options,
1038
+ indexesSymbols,
1039
+ };
1035
1040
  };
1036
1041
  const parseLayoutBlock = () => {
1037
1042
  let name;
package/dist/parser.mjs CHANGED
@@ -430,23 +430,20 @@ export const parse = (tokens) => {
430
430
  }
431
431
  };
432
432
  while (!match(TokenType.RightBracket)) {
433
- const { value: keyword, location } = current();
433
+ const { value: keyword, location } = consume(TokenType.Keyword, lexer.COLLECTION_KEYWORDS);
434
434
  switch (keyword) {
435
435
  case "writable":
436
436
  case "required": {
437
- consume(TokenType.Keyword);
438
437
  const { value, symbols } = parseArrayBlock();
439
438
  property[keyword] = value;
440
439
  property[AST.LOCATION_SYMBOL].arrays[keyword] = symbols;
441
440
  break;
442
441
  }
443
442
  case "properties": {
444
- consume(TokenType.Keyword);
445
443
  nestedProperties = parsePropertiesBlock(options);
446
444
  break;
447
445
  }
448
446
  case "additionalProperties": {
449
- consume(TokenType.Keyword);
450
447
  if (match(TokenType.Boolean)) {
451
448
  nestedAdditionalProperties = consume(TokenType.Boolean).value;
452
449
  } else {
@@ -707,7 +704,9 @@ export const parse = (tokens) => {
707
704
  break;
708
705
  }
709
706
  case "search": {
710
- node[keyword] = parseSearchBlock();
707
+ const { options, indexesSymbols } = parseSearchBlock();
708
+ node[keyword] = options;
709
+ node[AST.LOCATION_SYMBOL].searchIndexes = indexesSymbols;
711
710
  break;
712
711
  }
713
712
  case "layout": {
@@ -945,9 +944,16 @@ export const parse = (tokens) => {
945
944
  const parseSearchBlock = () => {
946
945
  const searchSlots = {};
947
946
  const { location } = consume(TokenType.LeftBracket);
947
+ let indexesSymbols;
948
948
  while (!match(TokenType.RightBracket)) {
949
949
  const { value: keyword } = consume(TokenType.Keyword, lexer.COLLECTION_SEARCH_KEYWORDS);
950
950
  switch (keyword) {
951
+ case "indexes": {
952
+ const { value, symbols } = parseArrayBlock();
953
+ searchSlots[keyword] = value;
954
+ indexesSymbols = symbols;
955
+ break;
956
+ }
951
957
  case "placeholder": {
952
958
  const { value } = consume(TokenType.QuotedString);
953
959
  searchSlots[keyword] = value;
@@ -958,11 +964,6 @@ export const parse = (tokens) => {
958
964
  searchSlots[keyword] = value;
959
965
  break;
960
966
  }
961
- case "indexes": {
962
- const { value } = parseArrayBlock();
963
- searchSlots[keyword] = value;
964
- break;
965
- }
966
967
  }
967
968
  }
968
969
  const { indexes } = searchSlots;
@@ -970,10 +971,14 @@ export const parse = (tokens) => {
970
971
  throw new Diagnostic('"indexes" option is required', location);
971
972
  }
972
973
  consume(TokenType.RightBracket);
973
- return {
974
+ const options = {
974
975
  ...searchSlots,
975
976
  indexes
976
977
  };
978
+ return {
979
+ options,
980
+ indexesSymbols
981
+ };
977
982
  };
978
983
  const parseLayoutBlock = () => {
979
984
  let name;
package/dist/semantic.js CHANGED
@@ -208,6 +208,15 @@ const analyze = async (ast, options, errors = []) => {
208
208
  }
209
209
  }
210
210
  }
211
+ if (node.search) {
212
+ for (const [i, symbol] of node[AST.LOCATION_SYMBOL].searchIndexes.entries()) {
213
+ const propName = node.search.indexes[i];
214
+ if (!(propName in node.properties)) {
215
+ const location = parser_js_1.locationMap.get(symbol);
216
+ errors.push(new diagnostic_js_1.Diagnostic(`invalid property "${propName}"`, location));
217
+ }
218
+ }
219
+ }
211
220
  }
212
221
  for (const node of ast.contracts) {
213
222
  if (node.payload) {
package/dist/semantic.mjs CHANGED
@@ -168,6 +168,15 @@ export const analyze = async (ast, options, errors = []) => {
168
168
  }
169
169
  }
170
170
  }
171
+ if (node.search) {
172
+ for (const [i, symbol] of node[AST.LOCATION_SYMBOL].searchIndexes.entries()) {
173
+ const propName = node.search.indexes[i];
174
+ if (!(propName in node.properties)) {
175
+ const location = locationMap.get(symbol);
176
+ errors.push(new Diagnostic(`invalid property "${propName}"`, location));
177
+ }
178
+ }
179
+ }
171
180
  }
172
181
  for (const node of ast.contracts) {
173
182
  if (node.payload) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/compiler",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
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.150",
25
- "@aeriajs/types": "^0.0.128"
24
+ "@aeriajs/common": "^0.0.151",
25
+ "@aeriajs/types": "^0.0.129"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@aeriajs/common": "link:../common",