@aeriajs/compiler 0.0.61 → 0.0.63

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/semantic.mjs DELETED
@@ -1,202 +0,0 @@
1
- "use strict";
2
- import { isValidCollection } from "@aeriajs/common";
3
- import { locationMap } from "./parser.mjs";
4
- import { Diagnostic } from "./diagnostic.mjs";
5
- import * as AST from "./ast.mjs";
6
- const collectionHasProperty = async (collection, propName, options = {}) => {
7
- let hasProperty = propName in collection.properties;
8
- if (!hasProperty) {
9
- if (collection.extends) {
10
- if (options.languageServer) {
11
- return true;
12
- }
13
- const { importPath, symbolName } = collection.extends;
14
- const { [symbolName]: importedCollection } = await import(importPath);
15
- if (!isValidCollection(importedCollection)) {
16
- throw new Error();
17
- }
18
- hasProperty = propName in importedCollection.description.properties;
19
- }
20
- }
21
- return hasProperty;
22
- };
23
- export const analyze = async (ast, options, errors = []) => {
24
- const checkCollectionForeignProperties = async (foreignCollection, property, attributeName) => {
25
- if (!property[attributeName]) {
26
- return;
27
- }
28
- for (const foreignPropName of property[attributeName]) {
29
- if (!await collectionHasProperty(foreignCollection, foreignPropName, options)) {
30
- let location;
31
- if (property[AST.LOCATION_SYMBOL]) {
32
- location = locationMap.get(property[AST.LOCATION_SYMBOL].attributes[attributeName]);
33
- }
34
- errors.push(new Diagnostic(`collection "${foreignCollection.name}" hasn't such property "${foreignPropName}"`, location));
35
- }
36
- }
37
- };
38
- const checkCollectionLocalProperties = async (node, attributeName) => {
39
- if (!node[attributeName]) {
40
- return;
41
- }
42
- for (const index in node[attributeName]) {
43
- const propName = node[attributeName][index];
44
- if (!await collectionHasProperty(node, propName, options)) {
45
- const symbol = node[AST.LOCATION_SYMBOL].arrays[attributeName][index];
46
- const location = locationMap.get(symbol);
47
- errors.push(new Diagnostic(`collection "${node.name}" hasn't such property "${propName}"`, location));
48
- }
49
- }
50
- };
51
- const checkObjectLocalProperties = async (node, attributeName) => {
52
- if (!("properties" in node.property) || !node.property[attributeName]) {
53
- return;
54
- }
55
- for (const index in node.property[attributeName]) {
56
- const propName = node.property[attributeName][index];
57
- if (!(propName in node.nestedProperties)) {
58
- const symbol = node.property[AST.LOCATION_SYMBOL].arrays[attributeName][index];
59
- const location = locationMap.get(symbol);
60
- console.log(JSON.stringify(node));
61
- errors.push(new Diagnostic(`object hasn't such property "${propName}"`, location));
62
- }
63
- }
64
- };
65
- const recurseProperty = async (node) => {
66
- if ("type" in node.property && node.property.type === "object") {
67
- if (typeof node.nestedAdditionalProperties === "object") {
68
- await recurseProperty(node.nestedAdditionalProperties);
69
- }
70
- if (node.nestedProperties) {
71
- await checkObjectLocalProperties(node, "required");
72
- await checkObjectLocalProperties(node, "writable");
73
- await checkObjectLocalProperties(node, "form");
74
- for (const propName in node.nestedProperties) {
75
- const subProperty = node.nestedProperties[propName];
76
- await recurseProperty(subProperty);
77
- }
78
- }
79
- } else if ("$ref" in node.property) {
80
- const refName = node.property.$ref;
81
- const foreignCollection = ast.collections.find(({ name }) => name === refName);
82
- if (!foreignCollection) {
83
- const location = locationMap.get(node.property[AST.LOCATION_SYMBOL].type);
84
- errors.push(new Diagnostic(`invalid reference "${refName}"`, location));
85
- return;
86
- }
87
- await checkCollectionForeignProperties(foreignCollection, node.property, "indexes");
88
- await checkCollectionForeignProperties(foreignCollection, node.property, "populate");
89
- await checkCollectionForeignProperties(foreignCollection, node.property, "form");
90
- if (node.property.constraints) {
91
- for (const [name, symbol] of node.property[AST.LOCATION_SYMBOL].contraintTerms) {
92
- if (!await collectionHasProperty(foreignCollection, name, options)) {
93
- const location = locationMap.get(symbol);
94
- errors.push(new Diagnostic(`left operand "${name}" does not exist on collection "${foreignCollection.name}"`, location));
95
- }
96
- }
97
- }
98
- } else if ("items" in node.property) {
99
- await recurseProperty({
100
- kind: "property",
101
- property: node.property.items
102
- });
103
- }
104
- };
105
- for (const node of ast.collections) {
106
- await checkCollectionLocalProperties(node, "indexes");
107
- await checkCollectionLocalProperties(node, "filters");
108
- await checkCollectionLocalProperties(node, "form");
109
- await checkCollectionLocalProperties(node, "table");
110
- await checkCollectionLocalProperties(node, "tableMeta");
111
- if (node.required) {
112
- const propNames = Array.isArray(node.required) ? node.required : Object.keys(node.required);
113
- for (const index in propNames) {
114
- const propName = propNames[index];
115
- if (!(propName in node.properties)) {
116
- const symbol = node[AST.LOCATION_SYMBOL].required[index];
117
- const location = locationMap.get(symbol);
118
- errors.push(new Diagnostic(`collection "${node.name}" hasn't such property "${propName}"`, location));
119
- }
120
- }
121
- }
122
- for (const propName in node.properties) {
123
- const subNode = node.properties[propName];
124
- await recurseProperty(subNode);
125
- }
126
- if (node[AST.LOCATION_SYMBOL].requiredTerms) {
127
- for (const [name, symbol] of node[AST.LOCATION_SYMBOL].requiredTerms) {
128
- if (!(name in node.properties)) {
129
- const location = locationMap.get(symbol);
130
- errors.push(new Diagnostic(`invalid left operand "${name}"`, location));
131
- }
132
- }
133
- }
134
- if (node.layout) {
135
- if (node.layout.options) {
136
- for (const [name, value] of Object.entries(node.layout[AST.LOCATION_SYMBOL].options)) {
137
- const option = node.layout.options[name];
138
- if (Array.isArray(option)) {
139
- for (const [i, propName] of option.entries()) {
140
- if (!(propName in node.properties)) {
141
- const location = locationMap.get(value[i]);
142
- errors.push(new Diagnostic(`invalid property "${propName}"`, location));
143
- }
144
- }
145
- } else {
146
- if (!(option in node.properties)) {
147
- const location = locationMap.get(value);
148
- errors.push(new Diagnostic(`invalid property "${option}"`, location));
149
- }
150
- }
151
- }
152
- }
153
- }
154
- if (node.formLayout) {
155
- if (node.formLayout.fields) {
156
- for (const [name, value] of Object.entries(node.formLayout[AST.LOCATION_SYMBOL].fields)) {
157
- if (!(name in node.properties)) {
158
- const location = locationMap.get(value.name);
159
- errors.push(new Diagnostic(`invalid property "${name}"`, location));
160
- }
161
- }
162
- }
163
- if (node.formLayout[AST.LOCATION_SYMBOL].terms) {
164
- for (const [name, symbol] of node.formLayout[AST.LOCATION_SYMBOL].terms) {
165
- if (!(name in node.properties)) {
166
- const location = locationMap.get(symbol);
167
- errors.push(new Diagnostic(`invalid left operand "${name}"`, location));
168
- }
169
- }
170
- }
171
- }
172
- if (node.search) {
173
- for (const [i, symbol] of node[AST.LOCATION_SYMBOL].searchIndexes.entries()) {
174
- const propName = node.search.indexes[i];
175
- if (!(propName in node.properties)) {
176
- const location = locationMap.get(symbol);
177
- errors.push(new Diagnostic(`invalid property "${propName}"`, location));
178
- }
179
- }
180
- }
181
- }
182
- for (const node of ast.contracts) {
183
- if (node.payload) {
184
- await recurseProperty(node.payload);
185
- }
186
- if (node.query) {
187
- await recurseProperty(node.query);
188
- }
189
- if (node.response) {
190
- if (Array.isArray(node.response)) {
191
- for (const subNode of node.response) {
192
- await recurseProperty(subNode);
193
- }
194
- } else {
195
- await recurseProperty(node.response);
196
- }
197
- }
198
- }
199
- return {
200
- errors
201
- };
202
- };
package/dist/token.mjs DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- export const TokenType = {
3
- LineBreak: "LINE_BREAK",
4
- Comment: "COMMENT",
5
- LeftBracket: "LEFT_BRACKET",
6
- RightBracket: "RIGHT_BRACKET",
7
- LeftParens: "LEFT_PARENS",
8
- RightParens: "RIGHT_PARENS",
9
- LeftSquareBracket: "LEFT_SQUARE_BRACKET",
10
- RightSquareBracket: "RIGHT_SQUARE_BRACKET",
11
- Pipe: "PIPE",
12
- Comma: "COMMA",
13
- Dot: "DOT",
14
- Number: "NUMBER",
15
- Boolean: "BOOLEAN",
16
- Null: "NULL",
17
- Keyword: "KEYWORD",
18
- Identifier: "IDENTIFIER",
19
- QuotedString: "QUOTED_STRING",
20
- AttributeName: "ATTRIBUTE_NAME",
21
- MacroName: "MACRO_NAME",
22
- Range: "RANGE",
23
- Operator: "OPERATOR"
24
- };
package/dist/types.mjs DELETED
@@ -1 +0,0 @@
1
- "use strict";
package/dist/utils.mjs DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- export const DEFAULT_EXPORT_SYMBOLS = {
3
- count: "aeria",
4
- get: "aeria",
5
- getAll: "aeria",
6
- insert: "aeria",
7
- remove: "aeria",
8
- removeAll: "aeria",
9
- removeFile: "aeria",
10
- unpaginatedGetAll: "aeria",
11
- upload: "aeria"
12
- };