@aeriajs/compiler 0.0.69 → 0.0.71
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 +1 -0
- package/dist/codegen/generateContracts.js +19 -13
- package/dist/lexer.d.ts +1 -1
- package/dist/lexer.js +1 -0
- package/dist/parser.js +6 -1
- package/package.json +1 -1
package/dist/ast.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ const makeJSContractsCode = (ast) => {
|
|
|
25
25
|
return `${modifierSymbol}(${stringify(unwrapPropertyNode(propertyNode))})`;
|
|
26
26
|
};
|
|
27
27
|
const declarations = ast.contracts.map((node) => {
|
|
28
|
-
const { name, kind, roles, response, ...contractProperty } = node;
|
|
28
|
+
const { name, kind, streamed, roles, response, ...contractProperty } = node;
|
|
29
29
|
let responseString;
|
|
30
30
|
if (response) {
|
|
31
31
|
responseString = '';
|
|
@@ -48,7 +48,10 @@ const makeJSContractsCode = (ast) => {
|
|
|
48
48
|
[UnquotedSymbol]: responseString,
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
if (
|
|
51
|
+
if (streamed !== undefined) {
|
|
52
|
+
contractSchema.streamed = streamed;
|
|
53
|
+
}
|
|
54
|
+
if (roles !== undefined) {
|
|
52
55
|
contractSchema.roles = roles;
|
|
53
56
|
}
|
|
54
57
|
return `export const ${name} = defineContract(${stringify(contractSchema)})`;
|
|
@@ -66,23 +69,26 @@ const getResponseSchema = (response) => {
|
|
|
66
69
|
};
|
|
67
70
|
const makeTSContractsCode = (ast) => {
|
|
68
71
|
return ast.contracts.map((node) => {
|
|
69
|
-
const { name, kind, roles, ...
|
|
70
|
-
let responseSchema
|
|
71
|
-
if (
|
|
72
|
-
if (Array.isArray(
|
|
73
|
-
responseSchema =
|
|
72
|
+
const { name, kind, streamed, roles, ...contractProperty } = node;
|
|
73
|
+
let responseSchema;
|
|
74
|
+
if (contractProperty.response) {
|
|
75
|
+
if (Array.isArray(contractProperty.response)) {
|
|
76
|
+
responseSchema = contractProperty.response.map(getResponseSchema);
|
|
74
77
|
}
|
|
75
78
|
else {
|
|
76
|
-
responseSchema = getResponseSchema(
|
|
79
|
+
responseSchema = getResponseSchema(contractProperty.response);
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
|
-
const
|
|
82
|
+
const contractSchema = recursivelyUnwrapPropertyNodes(contractProperty);
|
|
80
83
|
if (responseSchema) {
|
|
81
|
-
|
|
84
|
+
contractSchema.response = responseSchema;
|
|
82
85
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
86
|
+
if (streamed !== undefined) {
|
|
87
|
+
contractSchema.streamed = streamed;
|
|
88
|
+
}
|
|
89
|
+
if (roles !== undefined) {
|
|
90
|
+
contractSchema.roles = roles;
|
|
85
91
|
}
|
|
86
|
-
return `export declare const ${node.name}: ${stringify(
|
|
92
|
+
return `export declare const ${node.name}: ${stringify(contractSchema)}`;
|
|
87
93
|
}).join('\n\n');
|
|
88
94
|
};
|
package/dist/lexer.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const COLLECTION_SEARCH_KEYWORDS: readonly ["indexes", "placehold
|
|
|
6
6
|
export declare const COLLECTION_LAYOUT_KEYWORDS: readonly ["name", "options"];
|
|
7
7
|
export declare const COLLECTION_LAYOUT_OPTIONS_KEYWORDS: readonly ["title", "picture", "badge", "information", "active", "translateBadge"];
|
|
8
8
|
export declare const COLLECTION_FORM_LAYOUT_KEYWORDS: readonly ["fields", "if", "span", "verticalSpacing", "separator"];
|
|
9
|
-
export declare const CONTRACT_KEYWORDS: readonly ["roles", "payload", "query", "response"];
|
|
9
|
+
export declare const CONTRACT_KEYWORDS: readonly ["streamed", "roles", "payload", "query", "response"];
|
|
10
10
|
export declare const TOPLEVEL_KEYWORDS: readonly ["collection", "contract", "functionset"];
|
|
11
11
|
export declare const MISC_KEYWORDS: readonly ["extends"];
|
|
12
12
|
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 COLLECTION_FORM_LAYOUT_KEYWORDS[number] | typeof CONTRACT_KEYWORDS[number] | typeof TOPLEVEL_KEYWORDS[number] | typeof MISC_KEYWORDS[number];
|
package/dist/lexer.js
CHANGED
package/dist/parser.js
CHANGED
|
@@ -419,7 +419,7 @@ export const parse = (tokens) => {
|
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
consume(TokenType.RightSquareBracket);
|
|
422
|
-
const { property: items, nestedProperties } = parsePropertyType(options);
|
|
422
|
+
const { property: items, nestedProperties, nestedAdditionalProperties } = parsePropertyType(options);
|
|
423
423
|
property = {
|
|
424
424
|
...arrayProperty,
|
|
425
425
|
items,
|
|
@@ -429,6 +429,7 @@ export const parse = (tokens) => {
|
|
|
429
429
|
kind: 'property',
|
|
430
430
|
property,
|
|
431
431
|
nestedProperties,
|
|
432
|
+
nestedAdditionalProperties,
|
|
432
433
|
};
|
|
433
434
|
}
|
|
434
435
|
locationMap.set(typeSymbol, current().location);
|
|
@@ -781,6 +782,10 @@ export const parse = (tokens) => {
|
|
|
781
782
|
while (!match(TokenType.RightBracket)) {
|
|
782
783
|
const { value: keyword } = consume(TokenType.Keyword, lexer.CONTRACT_KEYWORDS);
|
|
783
784
|
switch (keyword) {
|
|
785
|
+
case 'streamed': {
|
|
786
|
+
node.streamed = consume(TokenType.Boolean).value;
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
784
789
|
case 'roles': {
|
|
785
790
|
node.roles = parseAccessCondition({
|
|
786
791
|
arrayBlock: true,
|