@aeriajs/compiler 0.0.23 → 0.0.24

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
@@ -1,4 +1,4 @@
1
- import type { Property, AccessCondition, CollectionActions, SearchOptions, DescriptionPreset, Icon, OwnershipMode } from '@aeriajs/types';
1
+ import type { Property, AccessCondition, CollectionActions, SearchOptions, DescriptionPreset, Icon, OwnershipMode, Layout } from '@aeriajs/types';
2
2
  import type { ArrayProperties } from './utils.js';
3
3
  export declare const LOCATION_SYMBOL: unique symbol;
4
4
  export declare const PropertyType: {
@@ -53,6 +53,7 @@ export type CollectionNode = NodeBase<'collection'> & {
53
53
  table?: string[];
54
54
  filters?: string[];
55
55
  search?: SearchOptions<any>;
56
+ layout?: Layout;
56
57
  [LOCATION_SYMBOL]: {
57
58
  arrays: {
58
59
  [P in ArrayProperties<CollectionNode>]?: symbol[];
@@ -77,6 +77,9 @@ const makeJSCollectionSchema = (collectionNode, collectionId) => {
77
77
  case 'search':
78
78
  collectionSchema.description[key] = collectionNode[key];
79
79
  break;
80
+ case 'layout':
81
+ collectionSchema.description[key] = collectionNode[key];
82
+ break;
80
83
  case 'required':
81
84
  collectionSchema.description[key] = collectionNode[key];
82
85
  break;
@@ -70,6 +70,9 @@ const makeJSCollectionSchema = (collectionNode, collectionId) => {
70
70
  case "search":
71
71
  collectionSchema.description[key] = collectionNode[key];
72
72
  break;
73
+ case "layout":
74
+ collectionSchema.description[key] = collectionNode[key];
75
+ break;
73
76
  case "required":
74
77
  collectionSchema.description[key] = collectionNode[key];
75
78
  break;
package/dist/lexer.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import { type Token } from './token.js';
2
2
  import { Diagnostic } from './diagnostic.js';
3
- export type Keyword = typeof COLLECTION_KEYWORDS[number] | typeof COLLECTION_ACTIONS_KEYWORDS[number] | typeof COLLECTION_SEARCH_KEYWORDS[number] | typeof CONTRACT_KEYWORDS[number] | typeof TOPLEVEL_KEYWORDS[number] | typeof MISC_KEYWORDS[number];
4
- export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "functions", "icon", "indexes", "individualActions", "owned", "presets", "properties", "required", "search", "table"];
3
+ export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "functions", "icon", "indexes", "individualActions", "layout", "owned", "presets", "properties", "required", "search", "table"];
5
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"];
6
5
  export declare const COLLECTION_SEARCH_KEYWORDS: readonly ["indexes", "placeholder", "exactMatches"];
6
+ export declare const COLLECTION_LAYOUT_KEYWORDS: readonly ["name", "options"];
7
+ export declare const COLLECTION_LAYOUT_OPTIONS_KEYWORDS: readonly ["title", "picture", "badge", "information", "active", "translateBadge"];
7
8
  export declare const CONTRACT_KEYWORDS: readonly ["roles", "payload", "query", "response"];
8
9
  export declare const TOPLEVEL_KEYWORDS: readonly ["collection", "contract", "functionset"];
9
10
  export declare const MISC_KEYWORDS: readonly ["extends"];
11
+ export type Keyword = typeof COLLECTION_KEYWORDS[number] | typeof COLLECTION_ACTIONS_KEYWORDS[number] | typeof COLLECTION_SEARCH_KEYWORDS[number] | typeof COLLECTION_LAYOUT_KEYWORDS[number] | typeof COLLECTION_LAYOUT_OPTIONS_KEYWORDS[number] | typeof CONTRACT_KEYWORDS[number] | typeof TOPLEVEL_KEYWORDS[number] | typeof MISC_KEYWORDS[number];
10
12
  export declare const KEYWORDS: Keyword[];
11
13
  export declare const tokenize: (rawInput: string) => {
12
14
  tokens: Token[];
package/dist/lexer.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tokenize = exports.KEYWORDS = exports.MISC_KEYWORDS = exports.TOPLEVEL_KEYWORDS = exports.CONTRACT_KEYWORDS = exports.COLLECTION_SEARCH_KEYWORDS = exports.COLLECTION_ACTIONS_KEYWORDS = exports.COLLECTION_KEYWORDS = void 0;
3
+ exports.tokenize = exports.KEYWORDS = exports.MISC_KEYWORDS = exports.TOPLEVEL_KEYWORDS = exports.CONTRACT_KEYWORDS = exports.COLLECTION_LAYOUT_OPTIONS_KEYWORDS = exports.COLLECTION_LAYOUT_KEYWORDS = exports.COLLECTION_SEARCH_KEYWORDS = exports.COLLECTION_ACTIONS_KEYWORDS = exports.COLLECTION_KEYWORDS = void 0;
4
4
  const token_js_1 = require("./token.js");
5
5
  const diagnostic_js_1 = require("./diagnostic.js");
6
6
  exports.COLLECTION_KEYWORDS = [
@@ -12,6 +12,7 @@ exports.COLLECTION_KEYWORDS = [
12
12
  'icon',
13
13
  'indexes',
14
14
  'individualActions',
15
+ 'layout',
15
16
  'owned',
16
17
  'presets',
17
18
  'properties',
@@ -43,6 +44,18 @@ exports.COLLECTION_SEARCH_KEYWORDS = [
43
44
  'placeholder',
44
45
  'exactMatches',
45
46
  ];
47
+ exports.COLLECTION_LAYOUT_KEYWORDS = [
48
+ 'name',
49
+ 'options',
50
+ ];
51
+ exports.COLLECTION_LAYOUT_OPTIONS_KEYWORDS = [
52
+ 'title',
53
+ 'picture',
54
+ 'badge',
55
+ 'information',
56
+ 'active',
57
+ 'translateBadge',
58
+ ];
46
59
  exports.CONTRACT_KEYWORDS = [
47
60
  'roles',
48
61
  'payload',
@@ -55,7 +68,7 @@ exports.TOPLEVEL_KEYWORDS = [
55
68
  'functionset',
56
69
  ];
57
70
  exports.MISC_KEYWORDS = ['extends'];
58
- exports.KEYWORDS = [].concat(exports.COLLECTION_KEYWORDS, exports.COLLECTION_ACTIONS_KEYWORDS, exports.COLLECTION_SEARCH_KEYWORDS, exports.CONTRACT_KEYWORDS, exports.TOPLEVEL_KEYWORDS, exports.MISC_KEYWORDS);
71
+ exports.KEYWORDS = [].concat(exports.COLLECTION_KEYWORDS, exports.COLLECTION_ACTIONS_KEYWORDS, exports.COLLECTION_SEARCH_KEYWORDS, exports.COLLECTION_LAYOUT_KEYWORDS, exports.COLLECTION_LAYOUT_OPTIONS_KEYWORDS, exports.CONTRACT_KEYWORDS, exports.TOPLEVEL_KEYWORDS, exports.MISC_KEYWORDS);
59
72
  const keywordsSet = new Set();
60
73
  for (const keyword of exports.KEYWORDS) {
61
74
  keywordsSet.add(keyword);
@@ -234,12 +247,21 @@ const tokenize = function (rawInput) {
234
247
  switch (type) {
235
248
  case token_js_1.TokenType.LeftBracket: {
236
249
  const lastToken = tokens.at(-1);
237
- if (lastToken) {
238
- if (lastToken.value === 'properties') {
239
- state.inPropertiesStack.push(true);
240
- }
241
- else {
242
- state.inPropertiesStack.push(false);
250
+ if (lastToken && lastToken.type === token_js_1.TokenType.Keyword) {
251
+ switch (lastToken.value) {
252
+ case 'form':
253
+ case 'table':
254
+ case 'indexes':
255
+ case 'filters':
256
+ case 'writable':
257
+ case 'required':
258
+ case 'properties': {
259
+ state.inPropertiesStack.push(true);
260
+ break;
261
+ }
262
+ default: {
263
+ state.inPropertiesStack.push(false);
264
+ }
243
265
  }
244
266
  }
245
267
  break;
package/dist/lexer.mjs CHANGED
@@ -10,6 +10,7 @@ export const COLLECTION_KEYWORDS = [
10
10
  "icon",
11
11
  "indexes",
12
12
  "individualActions",
13
+ "layout",
13
14
  "owned",
14
15
  "presets",
15
16
  "properties",
@@ -41,6 +42,18 @@ export const COLLECTION_SEARCH_KEYWORDS = [
41
42
  "placeholder",
42
43
  "exactMatches"
43
44
  ];
45
+ export const COLLECTION_LAYOUT_KEYWORDS = [
46
+ "name",
47
+ "options"
48
+ ];
49
+ export const COLLECTION_LAYOUT_OPTIONS_KEYWORDS = [
50
+ "title",
51
+ "picture",
52
+ "badge",
53
+ "information",
54
+ "active",
55
+ "translateBadge"
56
+ ];
44
57
  export const CONTRACT_KEYWORDS = [
45
58
  "roles",
46
59
  "payload",
@@ -57,6 +70,8 @@ export const KEYWORDS = [].concat(
57
70
  COLLECTION_KEYWORDS,
58
71
  COLLECTION_ACTIONS_KEYWORDS,
59
72
  COLLECTION_SEARCH_KEYWORDS,
73
+ COLLECTION_LAYOUT_KEYWORDS,
74
+ COLLECTION_LAYOUT_OPTIONS_KEYWORDS,
60
75
  CONTRACT_KEYWORDS,
61
76
  TOPLEVEL_KEYWORDS,
62
77
  MISC_KEYWORDS
@@ -234,11 +249,21 @@ export const tokenize = function(rawInput) {
234
249
  switch (type) {
235
250
  case TokenType.LeftBracket: {
236
251
  const lastToken = tokens.at(-1);
237
- if (lastToken) {
238
- if (lastToken.value === "properties") {
239
- state.inPropertiesStack.push(true);
240
- } else {
241
- state.inPropertiesStack.push(false);
252
+ if (lastToken && lastToken.type === TokenType.Keyword) {
253
+ switch (lastToken.value) {
254
+ case "form":
255
+ case "table":
256
+ case "indexes":
257
+ case "filters":
258
+ case "writable":
259
+ case "required":
260
+ case "properties": {
261
+ state.inPropertiesStack.push(true);
262
+ break;
263
+ }
264
+ default: {
265
+ state.inPropertiesStack.push(false);
266
+ }
242
267
  }
243
268
  }
244
269
  break;
package/dist/parser.js CHANGED
@@ -727,6 +727,10 @@ const parse = (tokens) => {
727
727
  node[keyword] = parseSearchBlock();
728
728
  break;
729
729
  }
730
+ case 'layout': {
731
+ node[keyword] = parseLayoutBlock();
732
+ break;
733
+ }
730
734
  }
731
735
  }
732
736
  catch (err) {
@@ -978,6 +982,61 @@ const parse = (tokens) => {
978
982
  indexes,
979
983
  };
980
984
  };
985
+ const parseLayoutBlock = () => {
986
+ let name;
987
+ const options = {};
988
+ const { location } = consume(token_js_1.TokenType.LeftBracket);
989
+ while (!match(token_js_1.TokenType.RightBracket)) {
990
+ const { value: keyword } = consume(token_js_1.TokenType.Keyword, lexer.COLLECTION_LAYOUT_KEYWORDS);
991
+ switch (keyword) {
992
+ case 'name': {
993
+ name = consume(token_js_1.TokenType.QuotedString, types_1.LAYOUT_NAMES).value;
994
+ break;
995
+ }
996
+ case 'options':
997
+ {
998
+ consume(token_js_1.TokenType.LeftBracket);
999
+ while (!match(token_js_1.TokenType.RightBracket)) {
1000
+ const { value: optionsKeyword } = consume(token_js_1.TokenType.Keyword, lexer.COLLECTION_LAYOUT_OPTIONS_KEYWORDS);
1001
+ switch (optionsKeyword) {
1002
+ case 'active':
1003
+ case 'title':
1004
+ case 'picture':
1005
+ case 'badge': {
1006
+ const { value } = consume(token_js_1.TokenType.QuotedString);
1007
+ options[optionsKeyword] = value;
1008
+ break;
1009
+ }
1010
+ case 'information': {
1011
+ if (match(token_js_1.TokenType.LeftBracket)) {
1012
+ options[optionsKeyword] = parseArrayBlock().value;
1013
+ }
1014
+ else {
1015
+ options[optionsKeyword] = consume(token_js_1.TokenType.QuotedString).value;
1016
+ }
1017
+ break;
1018
+ }
1019
+ case 'translateBadge': {
1020
+ const { value } = consume(token_js_1.TokenType.Boolean);
1021
+ options[optionsKeyword] = value;
1022
+ break;
1023
+ }
1024
+ }
1025
+ }
1026
+ }
1027
+ consume(token_js_1.TokenType.RightBracket);
1028
+ break;
1029
+ }
1030
+ }
1031
+ if (!name) {
1032
+ throw new diagnostic_js_1.Diagnostic('layout must have a "name" property', location);
1033
+ }
1034
+ consume(token_js_1.TokenType.RightBracket);
1035
+ return {
1036
+ name,
1037
+ options,
1038
+ };
1039
+ };
981
1040
  while (index < tokens.length) {
982
1041
  const { value: declType, location } = current();
983
1042
  try {
package/dist/parser.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  import { TokenType } from "./token.mjs";
3
- import { DESCRIPTION_PRESETS, PROPERTY_ARRAY_ELEMENTS, PROPERTY_FORMATS, PROPERTY_INPUT_ELEMENTS, PROPERTY_INPUT_TYPES } from "@aeriajs/types";
3
+ import { DESCRIPTION_PRESETS, LAYOUT_NAMES, PROPERTY_ARRAY_ELEMENTS, PROPERTY_FORMATS, PROPERTY_INPUT_ELEMENTS, PROPERTY_INPUT_TYPES } from "@aeriajs/types";
4
4
  import { icons } from "@phosphor-icons/core";
5
5
  import { Diagnostic } from "./diagnostic.mjs";
6
6
  import * as AST from "./ast.mjs";
@@ -672,6 +672,10 @@ export const parse = (tokens) => {
672
672
  node[keyword] = parseSearchBlock();
673
673
  break;
674
674
  }
675
+ case "layout": {
676
+ node[keyword] = parseLayoutBlock();
677
+ break;
678
+ }
675
679
  }
676
680
  } catch (err) {
677
681
  if (err instanceof Diagnostic) {
@@ -919,6 +923,60 @@ export const parse = (tokens) => {
919
923
  indexes
920
924
  };
921
925
  };
926
+ const parseLayoutBlock = () => {
927
+ let name;
928
+ const options = {};
929
+ const { location } = consume(TokenType.LeftBracket);
930
+ while (!match(TokenType.RightBracket)) {
931
+ const { value: keyword } = consume(TokenType.Keyword, lexer.COLLECTION_LAYOUT_KEYWORDS);
932
+ switch (keyword) {
933
+ case "name": {
934
+ name = consume(TokenType.QuotedString, LAYOUT_NAMES).value;
935
+ break;
936
+ }
937
+ case "options":
938
+ {
939
+ consume(TokenType.LeftBracket);
940
+ while (!match(TokenType.RightBracket)) {
941
+ const { value: optionsKeyword } = consume(TokenType.Keyword, lexer.COLLECTION_LAYOUT_OPTIONS_KEYWORDS);
942
+ switch (optionsKeyword) {
943
+ case "active":
944
+ case "title":
945
+ case "picture":
946
+ case "badge": {
947
+ const { value } = consume(TokenType.QuotedString);
948
+ options[optionsKeyword] = value;
949
+ break;
950
+ }
951
+ case "information": {
952
+ if (match(TokenType.LeftBracket)) {
953
+ options[optionsKeyword] = parseArrayBlock().value;
954
+ } else {
955
+ options[optionsKeyword] = consume(TokenType.QuotedString).value;
956
+ }
957
+ break;
958
+ }
959
+ case "translateBadge": {
960
+ const { value } = consume(TokenType.Boolean);
961
+ options[optionsKeyword] = value;
962
+ break;
963
+ }
964
+ }
965
+ }
966
+ }
967
+ consume(TokenType.RightBracket);
968
+ break;
969
+ }
970
+ }
971
+ if (!name) {
972
+ throw new Diagnostic('layout must have a "name" property', location);
973
+ }
974
+ consume(TokenType.RightBracket);
975
+ return {
976
+ name,
977
+ options
978
+ };
979
+ };
922
980
  while (index < tokens.length) {
923
981
  const { value: declType, location } = current();
924
982
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/compiler",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
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.140",
25
- "@aeriajs/types": "^0.0.122"
24
+ "@aeriajs/common": "^0.0.141",
25
+ "@aeriajs/types": "^0.0.123"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@aeriajs/common": "link:../common",