@aeriajs/compiler 0.0.17 → 0.0.19

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
@@ -33,6 +33,7 @@ export type PropertyNode = NodeBase<'property'> & {
33
33
  };
34
34
  };
35
35
  nestedProperties?: Record<string, PropertyNode>;
36
+ nestedAdditionalProperties?: PropertyNode | boolean;
36
37
  };
37
38
  export type CollectionNode = NodeBase<'collection'> & {
38
39
  name: string;
@@ -19,7 +19,7 @@ const makeJSContractsCode = (contractAst) => {
19
19
  const getCodeForResponse = (responseProperty) => {
20
20
  const { kind, modifier, ...propertyNode } = responseProperty;
21
21
  if (!modifier) {
22
- return (0, utils_js_1.stringify)((0, utils_js_1.propertyToSchema)(propertyNode));
22
+ return (0, utils_js_1.stringify)((0, utils_js_1.unwrapPropertyNode)(propertyNode));
23
23
  }
24
24
  const modifierSymbol = responseProperty.modifier === 'Result'
25
25
  ? 'resultSchema'
@@ -27,7 +27,7 @@ const makeJSContractsCode = (contractAst) => {
27
27
  if (!imports.has(modifierSymbol)) {
28
28
  imports.add(modifierSymbol);
29
29
  }
30
- return `${modifierSymbol}(${(0, utils_js_1.stringify)((0, utils_js_1.propertyToSchema)(propertyNode))})`;
30
+ return `${modifierSymbol}(${(0, utils_js_1.stringify)((0, utils_js_1.unwrapPropertyNode)(propertyNode))})`;
31
31
  };
32
32
  const declarations = contractAst.map((contractNode) => {
33
33
  const { name, kind, roles, response, ...contractProperty } = contractNode;
@@ -47,7 +47,7 @@ const makeJSContractsCode = (contractAst) => {
47
47
  responseString = (0, utils_js_1.stringify)(getCodeForResponse(response));
48
48
  }
49
49
  }
50
- const contractSchema = (0, utils_js_1.getProperties)(contractProperty);
50
+ const contractSchema = (0, utils_js_1.recursivelyUnwrapPropertyNodes)(contractProperty);
51
51
  if (responseString) {
52
52
  contractSchema.response = {
53
53
  [utils_js_1.UnquotedSymbol]: responseString,
@@ -61,7 +61,7 @@ const makeJSContractsCode = (contractAst) => {
61
61
  return `import { ${Array.from(imports).join(', ')} } from \'aeria\'\n\n` + declarations;
62
62
  };
63
63
  const getResponseSchema = (response) => {
64
- const responseSchema = (0, utils_js_1.propertyToSchema)(response);
64
+ const responseSchema = (0, utils_js_1.unwrapPropertyNode)(response);
65
65
  if (!response.modifier) {
66
66
  return responseSchema;
67
67
  }
@@ -81,7 +81,7 @@ const makeTSContractsCode = (contractAst) => {
81
81
  responseSchema = getResponseSchema(contractSchema.response);
82
82
  }
83
83
  }
84
- const contractProperties = (0, utils_js_1.getProperties)(contractSchema);
84
+ const contractProperties = (0, utils_js_1.recursivelyUnwrapPropertyNodes)(contractSchema);
85
85
  if (responseSchema) {
86
86
  contractProperties.response = responseSchema;
87
87
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  import { errorSchema, resultSchema } from "@aeriajs/types";
3
- import { getProperties, propertyToSchema, stringify, UnquotedSymbol } from "./utils.mjs";
3
+ import { recursivelyUnwrapPropertyNodes, unwrapPropertyNode, stringify, UnquotedSymbol } from "./utils.mjs";
4
4
  export const generateContracts = (ast) => {
5
5
  const contractNodes = ast.filter((node) => node.kind === "contract");
6
6
  if (contractNodes.length === 0) {
@@ -16,13 +16,13 @@ const makeJSContractsCode = (contractAst) => {
16
16
  const getCodeForResponse = (responseProperty) => {
17
17
  const { kind, modifier, ...propertyNode } = responseProperty;
18
18
  if (!modifier) {
19
- return stringify(propertyToSchema(propertyNode));
19
+ return stringify(unwrapPropertyNode(propertyNode));
20
20
  }
21
21
  const modifierSymbol = responseProperty.modifier === "Result" ? "resultSchema" : "errorSchema";
22
22
  if (!imports.has(modifierSymbol)) {
23
23
  imports.add(modifierSymbol);
24
24
  }
25
- return `${modifierSymbol}(${stringify(propertyToSchema(propertyNode))})`;
25
+ return `${modifierSymbol}(${stringify(unwrapPropertyNode(propertyNode))})`;
26
26
  };
27
27
  const declarations = contractAst.map((contractNode) => {
28
28
  const { name, kind, roles, response, ...contractProperty } = contractNode;
@@ -41,7 +41,7 @@ const makeJSContractsCode = (contractAst) => {
41
41
  responseString = stringify(getCodeForResponse(response));
42
42
  }
43
43
  }
44
- const contractSchema = getProperties(contractProperty);
44
+ const contractSchema = recursivelyUnwrapPropertyNodes(contractProperty);
45
45
  if (responseString) {
46
46
  contractSchema.response = {
47
47
  [UnquotedSymbol]: responseString
@@ -57,7 +57,7 @@ const makeJSContractsCode = (contractAst) => {
57
57
  ` + declarations;
58
58
  };
59
59
  const getResponseSchema = (response) => {
60
- const responseSchema = propertyToSchema(response);
60
+ const responseSchema = unwrapPropertyNode(response);
61
61
  if (!response.modifier) {
62
62
  return responseSchema;
63
63
  }
@@ -74,7 +74,7 @@ const makeTSContractsCode = (contractAst) => {
74
74
  responseSchema = getResponseSchema(contractSchema.response);
75
75
  }
76
76
  }
77
- const contractProperties = getProperties(contractSchema);
77
+ const contractProperties = recursivelyUnwrapPropertyNodes(contractSchema);
78
78
  if (responseSchema) {
79
79
  contractProperties.response = responseSchema;
80
80
  }
@@ -47,7 +47,7 @@ const makeJSCollectionSchema = (collectionNode, collectionId) => {
47
47
  }
48
48
  switch (key) {
49
49
  case 'properties':
50
- collectionSchema.description[key] = (0, utils_js_1.getProperties)(collectionNode[key]);
50
+ collectionSchema.description[key] = (0, utils_js_1.recursivelyUnwrapPropertyNodes)(collectionNode[key]);
51
51
  break;
52
52
  case 'owned':
53
53
  collectionSchema.description[key] = collectionNode[key];
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- import { makeASTImports, getProperties, stringify, getExtendName, getCollectionId, UnquotedSymbol, getExposedFunctions, PACKAGE_NAME, DEFAULT_FUNCTIONS } from "./utils.mjs";
2
+ import { makeASTImports, recursivelyUnwrapPropertyNodes, stringify, getExtendName, getCollectionId, UnquotedSymbol, getExposedFunctions, PACKAGE_NAME, DEFAULT_FUNCTIONS } from "./utils.mjs";
3
3
  const initialImportedFunctions = [
4
4
  "extendCollection",
5
5
  "defineCollection"
@@ -40,7 +40,7 @@ const makeJSCollectionSchema = (collectionNode, collectionId) => {
40
40
  }
41
41
  switch (key) {
42
42
  case "properties":
43
- collectionSchema.description[key] = getProperties(collectionNode[key]);
43
+ collectionSchema.description[key] = recursivelyUnwrapPropertyNodes(collectionNode[key]);
44
44
  break;
45
45
  case "owned":
46
46
  collectionSchema.description[key] = collectionNode[key];
@@ -59,7 +59,7 @@ const makeTSCollectionSchema = (collectionNode, collectionId) => {
59
59
  }
60
60
  switch (key) {
61
61
  case 'properties':
62
- collectionSchema.description.properties = (0, utils_js_1.getProperties)(collectionNode[key]);
62
+ collectionSchema.description.properties = (0, utils_js_1.recursivelyUnwrapPropertyNodes)(collectionNode[key]);
63
63
  break;
64
64
  case 'owned':
65
65
  collectionSchema.description.owned = collectionNode[key];
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- import { getProperties, stringify, makeASTImports, resizeFirstChar, getCollectionId, UnquotedSymbol, getExposedFunctions, PACKAGE_NAME, DEFAULT_FUNCTIONS } from "./utils.mjs";
2
+ import { recursivelyUnwrapPropertyNodes, stringify, makeASTImports, resizeFirstChar, getCollectionId, UnquotedSymbol, getExposedFunctions, PACKAGE_NAME, DEFAULT_FUNCTIONS } from "./utils.mjs";
3
3
  const initialImportedTypes = [
4
4
  "Collection",
5
5
  "SchemaWithId",
@@ -54,7 +54,7 @@ const makeTSCollectionSchema = (collectionNode, collectionId) => {
54
54
  }
55
55
  switch (key) {
56
56
  case "properties":
57
- collectionSchema.description.properties = getProperties(collectionNode[key]);
57
+ collectionSchema.description.properties = recursivelyUnwrapPropertyNodes(collectionNode[key]);
58
58
  break;
59
59
  case "owned":
60
60
  collectionSchema.description.owned = collectionNode[key];
@@ -13,9 +13,9 @@ export declare const makeASTImports: (ast: AST.Node[], initialImports?: Record<s
13
13
  code: string[];
14
14
  modifiedSymbols: Record<string, string>;
15
15
  };
16
- export declare const propertyToSchema: ({ property, nestedProperties }: Pick<AST.PropertyNode, "property" | "nestedProperties">) => Property;
16
+ export declare const unwrapPropertyNode: ({ property, nestedProperties, nestedAdditionalProperties }: Pick<AST.PropertyNode, "property" | "nestedProperties" | "nestedAdditionalProperties">) => Property;
17
17
  /** Transforms the AST properties to the format of aeria schema properties */
18
- export declare const getProperties: <TProperties extends Record<string, AST.PropertyNode | AST.PropertyNode[]>, TReturnType = TProperties[keyof TProperties] extends Array<unknown> ? Record<string, Property[]> : Record<string, Property>>(properties: TProperties) => TReturnType;
18
+ export declare const recursivelyUnwrapPropertyNodes: <TProperties extends Record<string, AST.PropertyNode | AST.PropertyNode[]>, TReturnType = TProperties[keyof TProperties] extends Array<unknown> ? Record<string, Property[]> : Record<string, Property>>(properties: TProperties) => TReturnType;
19
19
  export declare const UnquotedSymbol: unique symbol;
20
20
  /** Serves to know if the value must be unquoted on strinfigy function */
21
21
  export type StringifyProperty = unknown | {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExtendName = exports.getCollectionId = exports.resizeFirstChar = exports.stringify = exports.UnquotedSymbol = exports.getProperties = exports.propertyToSchema = exports.makeASTImports = exports.getExposedFunctions = exports.ArraySymbol = exports.DEFAULT_FUNCTIONS = exports.PACKAGE_NAME = void 0;
3
+ exports.getExtendName = exports.getCollectionId = exports.resizeFirstChar = exports.stringify = exports.UnquotedSymbol = exports.recursivelyUnwrapPropertyNodes = exports.unwrapPropertyNode = exports.makeASTImports = exports.getExposedFunctions = exports.ArraySymbol = exports.DEFAULT_FUNCTIONS = exports.PACKAGE_NAME = void 0;
4
4
  exports.PACKAGE_NAME = 'aeria';
5
5
  exports.DEFAULT_FUNCTIONS = [
6
6
  'count',
@@ -55,41 +55,70 @@ const makeASTImports = (ast, initialImports) => {
55
55
  };
56
56
  };
57
57
  exports.makeASTImports = makeASTImports;
58
- const propertyToSchema = ({ property, nestedProperties }) => {
59
- const propertySchema = property;
60
- if ('$ref' in propertySchema) {
61
- propertySchema.$ref = (0, exports.getCollectionId)(propertySchema.$ref);
58
+ const unwrapPropertyNode = ({ property, nestedProperties, nestedAdditionalProperties }) => {
59
+ const propertyOrPropertyItems = 'items' in property
60
+ ? property.items
61
+ : property;
62
+ let unwrappedProperty = propertyOrPropertyItems;
63
+ if ('$ref' in propertyOrPropertyItems) {
64
+ unwrappedProperty = {
65
+ ...propertyOrPropertyItems,
66
+ $ref: (0, exports.getCollectionId)(propertyOrPropertyItems.$ref),
67
+ };
62
68
  }
63
- else if ('items' in propertySchema && '$ref' in propertySchema.items) {
64
- propertySchema.items.$ref = (0, exports.getCollectionId)(propertySchema.items.$ref);
65
- }
66
- if (nestedProperties && 'type' in propertySchema) {
67
- if (propertySchema.type === 'object' && 'properties' in propertySchema) {
68
- propertySchema.properties = (0, exports.getProperties)(nestedProperties);
69
+ else if ('type' in propertyOrPropertyItems && propertyOrPropertyItems.type === 'object') {
70
+ let properties;
71
+ let additionalProperties;
72
+ if (nestedProperties) {
73
+ properties = (0, exports.recursivelyUnwrapPropertyNodes)(nestedProperties);
74
+ }
75
+ if (nestedAdditionalProperties) {
76
+ additionalProperties = typeof nestedAdditionalProperties === 'boolean'
77
+ ? nestedAdditionalProperties
78
+ : (0, exports.unwrapPropertyNode)(nestedAdditionalProperties);
79
+ }
80
+ if (properties && additionalProperties) {
81
+ unwrappedProperty = {
82
+ ...propertyOrPropertyItems,
83
+ properties,
84
+ additionalProperties,
85
+ };
69
86
  }
70
- else if (propertySchema.type === 'array') {
71
- propertySchema.items = {
72
- type: 'object',
73
- properties: (0, exports.getProperties)(nestedProperties),
87
+ else if (properties) {
88
+ unwrappedProperty = {
89
+ ...propertyOrPropertyItems,
90
+ properties,
74
91
  };
75
92
  }
93
+ else if (additionalProperties) {
94
+ unwrappedProperty = {
95
+ ...propertyOrPropertyItems,
96
+ additionalProperties,
97
+ };
98
+ }
99
+ }
100
+ if ('items' in property) {
101
+ return {
102
+ ...property,
103
+ items: unwrappedProperty,
104
+ };
76
105
  }
77
- return propertySchema;
106
+ return unwrappedProperty;
78
107
  };
79
- exports.propertyToSchema = propertyToSchema;
108
+ exports.unwrapPropertyNode = unwrapPropertyNode;
80
109
  /** Transforms the AST properties to the format of aeria schema properties */
81
- const getProperties = (properties) => {
110
+ const recursivelyUnwrapPropertyNodes = (properties) => {
82
111
  return Object.entries(properties).reduce((acc, [key, value]) => {
83
112
  if (Array.isArray(value)) {
84
- acc[key] = value.map((propertyNode) => (0, exports.propertyToSchema)(propertyNode));
113
+ acc[key] = value.map((propertyNode) => (0, exports.unwrapPropertyNode)(propertyNode));
85
114
  }
86
115
  else {
87
- acc[key] = (0, exports.propertyToSchema)(value);
116
+ acc[key] = (0, exports.unwrapPropertyNode)(value);
88
117
  }
89
118
  return acc;
90
119
  }, {});
91
120
  };
92
- exports.getProperties = getProperties;
121
+ exports.recursivelyUnwrapPropertyNodes = recursivelyUnwrapPropertyNodes;
93
122
  exports.UnquotedSymbol = Symbol('unquoted');
94
123
  const isRecord = (value) => typeof value === 'object';
95
124
  /** Assure if specific fields needs to be between quotes or not */
@@ -48,31 +48,55 @@ export const makeASTImports = (ast, initialImports) => {
48
48
  modifiedSymbols
49
49
  };
50
50
  };
51
- export const propertyToSchema = ({ property, nestedProperties }) => {
52
- const propertySchema = property;
53
- if ("$ref" in propertySchema) {
54
- propertySchema.$ref = getCollectionId(propertySchema.$ref);
55
- } else if ("items" in propertySchema && "$ref" in propertySchema.items) {
56
- propertySchema.items.$ref = getCollectionId(propertySchema.items.$ref);
57
- }
58
- if (nestedProperties && "type" in propertySchema) {
59
- if (propertySchema.type === "object" && "properties" in propertySchema) {
60
- propertySchema.properties = getProperties(nestedProperties);
61
- } else if (propertySchema.type === "array") {
62
- propertySchema.items = {
63
- type: "object",
64
- properties: getProperties(nestedProperties)
51
+ export const unwrapPropertyNode = ({ property, nestedProperties, nestedAdditionalProperties }) => {
52
+ const propertyOrPropertyItems = "items" in property ? property.items : property;
53
+ let unwrappedProperty = propertyOrPropertyItems;
54
+ if ("$ref" in propertyOrPropertyItems) {
55
+ unwrappedProperty = {
56
+ ...propertyOrPropertyItems,
57
+ $ref: getCollectionId(propertyOrPropertyItems.$ref)
58
+ };
59
+ } else if ("type" in propertyOrPropertyItems && propertyOrPropertyItems.type === "object") {
60
+ let properties;
61
+ let additionalProperties;
62
+ if (nestedProperties) {
63
+ properties = recursivelyUnwrapPropertyNodes(nestedProperties);
64
+ }
65
+ if (nestedAdditionalProperties) {
66
+ additionalProperties = typeof nestedAdditionalProperties === "boolean" ? nestedAdditionalProperties : unwrapPropertyNode(nestedAdditionalProperties);
67
+ }
68
+ if (properties && additionalProperties) {
69
+ unwrappedProperty = {
70
+ ...propertyOrPropertyItems,
71
+ properties,
72
+ additionalProperties
73
+ };
74
+ } else if (properties) {
75
+ unwrappedProperty = {
76
+ ...propertyOrPropertyItems,
77
+ properties
78
+ };
79
+ } else if (additionalProperties) {
80
+ unwrappedProperty = {
81
+ ...propertyOrPropertyItems,
82
+ additionalProperties
65
83
  };
66
84
  }
67
85
  }
68
- return propertySchema;
86
+ if ("items" in property) {
87
+ return {
88
+ ...property,
89
+ items: unwrappedProperty
90
+ };
91
+ }
92
+ return unwrappedProperty;
69
93
  };
70
- export const getProperties = (properties) => {
94
+ export const recursivelyUnwrapPropertyNodes = (properties) => {
71
95
  return Object.entries(properties).reduce((acc, [key, value]) => {
72
96
  if (Array.isArray(value)) {
73
- acc[key] = value.map((propertyNode) => propertyToSchema(propertyNode));
97
+ acc[key] = value.map((propertyNode) => unwrapPropertyNode(propertyNode));
74
98
  } else {
75
- acc[key] = propertyToSchema(value);
99
+ acc[key] = unwrapPropertyNode(value);
76
100
  }
77
101
  return acc;
78
102
  }, {});
package/dist/lexer.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type Token } from './token.js';
2
2
  import { Diagnostic } from './diagnostic.js';
3
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", "filters", "form", "functions", "icon", "indexes", "individualActions", "owned", "presets", "properties", "required", "search", "table"];
4
+ export declare const COLLECTION_KEYWORDS: readonly ["actions", "additionalProperties", "filters", "form", "functions", "icon", "indexes", "individualActions", "owned", "presets", "properties", "required", "search", "table"];
5
5
  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
6
  export declare const COLLECTION_SEARCH_KEYWORDS: readonly ["indexes", "placeholder", "exactMatches"];
7
7
  export declare const CONTRACT_KEYWORDS: readonly ["roles", "payload", "query", "response"];
package/dist/lexer.js CHANGED
@@ -5,6 +5,7 @@ const token_js_1 = require("./token.js");
5
5
  const diagnostic_js_1 = require("./diagnostic.js");
6
6
  exports.COLLECTION_KEYWORDS = [
7
7
  'actions',
8
+ 'additionalProperties',
8
9
  'filters',
9
10
  'form',
10
11
  'functions',
package/dist/lexer.mjs CHANGED
@@ -3,6 +3,7 @@ import { TokenType } from "./token.mjs";
3
3
  import { Diagnostic } from "./diagnostic.mjs";
4
4
  export const COLLECTION_KEYWORDS = [
5
5
  "actions",
6
+ "additionalProperties",
6
7
  "filters",
7
8
  "form",
8
9
  "functions",
package/dist/parser.js CHANGED
@@ -378,6 +378,7 @@ const parse = (tokens) => {
378
378
  }) => {
379
379
  let property;
380
380
  let nestedProperties;
381
+ let nestedAdditionalProperties;
381
382
  let modifierToken;
382
383
  const typeSymbol = Symbol();
383
384
  if (match(token_js_1.TokenType.LeftSquareBracket)) {
@@ -469,6 +470,16 @@ const parse = (tokens) => {
469
470
  nestedProperties = parsePropertiesBlock(options);
470
471
  break;
471
472
  }
473
+ case 'additionalProperties': {
474
+ consume(token_js_1.TokenType.Keyword);
475
+ if (match(token_js_1.TokenType.Boolean)) {
476
+ nestedAdditionalProperties = consume(token_js_1.TokenType.Boolean).value;
477
+ }
478
+ else {
479
+ nestedAdditionalProperties = parsePropertyType();
480
+ }
481
+ break;
482
+ }
472
483
  default:
473
484
  throw new diagnostic_js_1.Diagnostic(`invalid keyword "${keyword}"`, location);
474
485
  }
@@ -545,6 +556,7 @@ const parse = (tokens) => {
545
556
  kind: 'property',
546
557
  property,
547
558
  nestedProperties,
559
+ nestedAdditionalProperties,
548
560
  };
549
561
  if (modifierToken) {
550
562
  node.modifier = modifierToken.value;
@@ -663,11 +675,14 @@ const parse = (tokens) => {
663
675
  try {
664
676
  switch (keyword) {
665
677
  case 'owned': {
666
- if (match(token_js_1.TokenType.QuotedString, [
667
- 'always',
668
- 'on-write',
669
- ])) {
670
- node.owned = consume(token_js_1.TokenType.QuotedString).value;
678
+ if (match(token_js_1.TokenType.Boolean)) {
679
+ node.owned = consume(token_js_1.TokenType.Boolean).value;
680
+ }
681
+ else {
682
+ node.owned = consume(token_js_1.TokenType.QuotedString, [
683
+ 'always',
684
+ 'on-write',
685
+ ]).value;
671
686
  }
672
687
  break;
673
688
  }
package/dist/parser.mjs CHANGED
@@ -336,6 +336,7 @@ export const parse = (tokens) => {
336
336
  }) => {
337
337
  let property;
338
338
  let nestedProperties;
339
+ let nestedAdditionalProperties;
339
340
  let modifierToken;
340
341
  const typeSymbol = Symbol();
341
342
  if (match(TokenType.LeftSquareBracket)) {
@@ -425,6 +426,15 @@ export const parse = (tokens) => {
425
426
  nestedProperties = parsePropertiesBlock(options);
426
427
  break;
427
428
  }
429
+ case "additionalProperties": {
430
+ consume(TokenType.Keyword);
431
+ if (match(TokenType.Boolean)) {
432
+ nestedAdditionalProperties = consume(TokenType.Boolean).value;
433
+ } else {
434
+ nestedAdditionalProperties = parsePropertyType();
435
+ }
436
+ break;
437
+ }
428
438
  default:
429
439
  throw new Diagnostic(`invalid keyword "${keyword}"`, location);
430
440
  }
@@ -497,7 +507,8 @@ export const parse = (tokens) => {
497
507
  const node = {
498
508
  kind: "property",
499
509
  property,
500
- nestedProperties
510
+ nestedProperties,
511
+ nestedAdditionalProperties
501
512
  };
502
513
  if (modifierToken) {
503
514
  node.modifier = modifierToken.value;
@@ -610,11 +621,13 @@ export const parse = (tokens) => {
610
621
  try {
611
622
  switch (keyword) {
612
623
  case "owned": {
613
- if (match(TokenType.QuotedString, [
614
- "always",
615
- "on-write"
616
- ])) {
617
- node.owned = consume(TokenType.QuotedString).value;
624
+ if (match(TokenType.Boolean)) {
625
+ node.owned = consume(TokenType.Boolean).value;
626
+ } else {
627
+ node.owned = consume(TokenType.QuotedString, [
628
+ "always",
629
+ "on-write"
630
+ ]).value;
618
631
  }
619
632
  break;
620
633
  }
package/dist/semantic.js CHANGED
@@ -97,13 +97,18 @@ const analyze = async (ast, options, errors = []) => {
97
97
  }
98
98
  };
99
99
  const recurseProperty = async (node) => {
100
- if (node.nestedProperties && 'nestedProperties' in node) {
101
- await checkObjectLocalProperties(node, 'required');
102
- await checkObjectLocalProperties(node, 'writable');
103
- await checkObjectLocalProperties(node, 'form');
104
- for (const propName in node.nestedProperties) {
105
- const subProperty = node.nestedProperties[propName];
106
- await recurseProperty(subProperty);
100
+ if ('type' in node.property && node.property.type === 'object') {
101
+ if (typeof node.nestedAdditionalProperties === 'object') {
102
+ await recurseProperty(node.nestedAdditionalProperties);
103
+ }
104
+ if (node.nestedProperties) {
105
+ await checkObjectLocalProperties(node, 'required');
106
+ await checkObjectLocalProperties(node, 'writable');
107
+ await checkObjectLocalProperties(node, 'form');
108
+ for (const propName in node.nestedProperties) {
109
+ const subProperty = node.nestedProperties[propName];
110
+ await recurseProperty(subProperty);
111
+ }
107
112
  }
108
113
  }
109
114
  else if ('$ref' in node.property) {
@@ -118,6 +123,12 @@ const analyze = async (ast, options, errors = []) => {
118
123
  await checkCollectionForeignProperties(foreignCollection, node.property, 'populate');
119
124
  await checkCollectionForeignProperties(foreignCollection, node.property, 'form');
120
125
  }
126
+ else if ('items' in node.property) {
127
+ await recurseProperty({
128
+ kind: 'property',
129
+ property: node.property.items,
130
+ });
131
+ }
121
132
  };
122
133
  for (const node of ast.collections) {
123
134
  await checkCollectionLocalProperties(node, 'indexes');
package/dist/semantic.mjs CHANGED
@@ -62,13 +62,18 @@ export const analyze = async (ast, options, errors = []) => {
62
62
  }
63
63
  };
64
64
  const recurseProperty = async (node) => {
65
- if (node.nestedProperties && "nestedProperties" in node) {
66
- await checkObjectLocalProperties(node, "required");
67
- await checkObjectLocalProperties(node, "writable");
68
- await checkObjectLocalProperties(node, "form");
69
- for (const propName in node.nestedProperties) {
70
- const subProperty = node.nestedProperties[propName];
71
- await recurseProperty(subProperty);
65
+ if ("type" in node.property && node.property.type === "object") {
66
+ if (typeof node.nestedAdditionalProperties === "object") {
67
+ await recurseProperty(node.nestedAdditionalProperties);
68
+ }
69
+ if (node.nestedProperties) {
70
+ await checkObjectLocalProperties(node, "required");
71
+ await checkObjectLocalProperties(node, "writable");
72
+ await checkObjectLocalProperties(node, "form");
73
+ for (const propName in node.nestedProperties) {
74
+ const subProperty = node.nestedProperties[propName];
75
+ await recurseProperty(subProperty);
76
+ }
72
77
  }
73
78
  } else if ("$ref" in node.property) {
74
79
  const refName = node.property.$ref;
@@ -81,6 +86,11 @@ export const analyze = async (ast, options, errors = []) => {
81
86
  await checkCollectionForeignProperties(foreignCollection, node.property, "indexes");
82
87
  await checkCollectionForeignProperties(foreignCollection, node.property, "populate");
83
88
  await checkCollectionForeignProperties(foreignCollection, node.property, "form");
89
+ } else if ("items" in node.property) {
90
+ await recurseProperty({
91
+ kind: "property",
92
+ property: node.property.items
93
+ });
84
94
  }
85
95
  };
86
96
  for (const node of ast.collections) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/compiler",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
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.136",
25
- "@aeriajs/types": "^0.0.118"
24
+ "@aeriajs/common": "^0.0.137",
25
+ "@aeriajs/types": "^0.0.119"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@aeriajs/common": "link:../common",