@aeriajs/compiler 0.0.40 → 0.0.41
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/codegen/generateTSCollections.js +0 -2
- package/dist/codegen/utils.d.ts +4 -11
- package/dist/codegen/utils.js +2 -8
- package/dist/codegen/utils.mjs +1 -1
- package/dist/codegen.js +0 -14
- package/dist/parser.js +6 -0
- package/dist/parser.mjs +5 -0
- package/package.json +1 -1
|
@@ -17,7 +17,6 @@ const generateTSCollections = (ast) => {
|
|
|
17
17
|
return code;
|
|
18
18
|
};
|
|
19
19
|
exports.generateTSCollections = generateTSCollections;
|
|
20
|
-
/** Creates the code exporting the collection type, declaration, schema and extend for each collection and returns them in a string */
|
|
21
20
|
const makeTSCollections = (ast, modifiedSymbols) => {
|
|
22
21
|
const collectionCodes = {};
|
|
23
22
|
for (const collectionNode of ast) {
|
|
@@ -107,7 +106,6 @@ const makeTSCollectionSchema = (collectionNode, collectionId) => {
|
|
|
107
106
|
}
|
|
108
107
|
return (0, utils_js_1.stringify)(collectionSchema);
|
|
109
108
|
};
|
|
110
|
-
/** Turns each function to 'typeof functioName' if it's from aeria or not */
|
|
111
109
|
const makeTSFunctions = (functions) => {
|
|
112
110
|
return Object.keys(functions).reduce((acc, key) => {
|
|
113
111
|
acc[key] = {
|
package/dist/codegen/utils.d.ts
CHANGED
|
@@ -3,13 +3,14 @@ import type { Property } from '@aeriajs/types';
|
|
|
3
3
|
export declare const PACKAGE_NAME = "aeria";
|
|
4
4
|
export declare const MIDDLEWARES_RUNTIME_PATH = "../../../dist/middlewares/index.js";
|
|
5
5
|
export declare const DEFAULT_FUNCTIONS: string[];
|
|
6
|
+
export declare const UnquotedSymbol: unique symbol;
|
|
6
7
|
export declare const ArraySymbol: unique symbol;
|
|
8
|
+
export type StringifyProperty = unknown | {
|
|
9
|
+
[UnquotedSymbol]: string;
|
|
10
|
+
};
|
|
7
11
|
export declare const getExposedFunctions: (astFunctions: NonNullable<AST.CollectionNode["functions"]>) => {
|
|
8
12
|
[k: string]: import("@aeriajs/types").AccessCondition;
|
|
9
13
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Obs: It will save and return any modified symbols to avoid name duplication later
|
|
12
|
-
*/
|
|
13
14
|
export declare const makeASTImports: (ast: AST.Node[], initialImports?: Record<string, Set<string>>, options?: {
|
|
14
15
|
includeRuntimeOnlyImports: boolean;
|
|
15
16
|
}) => {
|
|
@@ -20,16 +21,8 @@ export declare const unwrapNode: <TNode extends {
|
|
|
20
21
|
kind: string;
|
|
21
22
|
}>(node: TNode) => Omit<TNode, "kind" | symbol>;
|
|
22
23
|
export declare const unwrapPropertyNode: ({ property, nestedProperties, nestedAdditionalProperties }: Pick<AST.PropertyNode, "property" | "nestedProperties" | "nestedAdditionalProperties">) => Property;
|
|
23
|
-
/** Transforms the AST properties to the format of aeria schema properties */
|
|
24
24
|
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;
|
|
25
|
-
export declare const UnquotedSymbol: unique symbol;
|
|
26
|
-
/** Serves to know if the value must be unquoted on strinfigy function */
|
|
27
|
-
export type StringifyProperty = unknown | {
|
|
28
|
-
[UnquotedSymbol]: string;
|
|
29
|
-
};
|
|
30
|
-
/** Assure if specific fields needs to be between quotes or not */
|
|
31
25
|
export declare const stringify: (value: StringifyProperty, parents?: (symbol | string)[]) => string;
|
|
32
|
-
/** Used to make the id and the schema name of the collection */
|
|
33
26
|
export declare const resizeFirstChar: (text: string, capitalize: boolean) => string;
|
|
34
27
|
export declare const getCollectionId: (name: string) => string;
|
|
35
28
|
export declare const getExtendName: (name: string) => string;
|
package/dist/codegen/utils.js
CHANGED
|
@@ -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.
|
|
3
|
+
exports.getExtendName = exports.getCollectionId = exports.resizeFirstChar = exports.stringify = exports.recursivelyUnwrapPropertyNodes = exports.unwrapPropertyNode = exports.unwrapNode = exports.makeASTImports = exports.getExposedFunctions = exports.ArraySymbol = exports.UnquotedSymbol = exports.DEFAULT_FUNCTIONS = exports.MIDDLEWARES_RUNTIME_PATH = exports.PACKAGE_NAME = void 0;
|
|
4
4
|
exports.PACKAGE_NAME = 'aeria';
|
|
5
5
|
exports.MIDDLEWARES_RUNTIME_PATH = '../../../dist/middlewares/index.js';
|
|
6
6
|
exports.DEFAULT_FUNCTIONS = [
|
|
@@ -14,6 +14,7 @@ exports.DEFAULT_FUNCTIONS = [
|
|
|
14
14
|
'unpaginatedGetAll',
|
|
15
15
|
'upload',
|
|
16
16
|
];
|
|
17
|
+
exports.UnquotedSymbol = Symbol('unquoted');
|
|
17
18
|
exports.ArraySymbol = Symbol('array');
|
|
18
19
|
const getExposedFunctions = (astFunctions) => {
|
|
19
20
|
return Object.fromEntries(Object.entries(astFunctions).map(([key, value]) => [
|
|
@@ -22,9 +23,6 @@ const getExposedFunctions = (astFunctions) => {
|
|
|
22
23
|
]));
|
|
23
24
|
};
|
|
24
25
|
exports.getExposedFunctions = getExposedFunctions;
|
|
25
|
-
/**
|
|
26
|
-
* Obs: It will save and return any modified symbols to avoid name duplication later
|
|
27
|
-
*/
|
|
28
26
|
const makeASTImports = (ast, initialImports, options = {
|
|
29
27
|
includeRuntimeOnlyImports: false,
|
|
30
28
|
}) => {
|
|
@@ -121,7 +119,6 @@ const unwrapPropertyNode = ({ property, nestedProperties, nestedAdditionalProper
|
|
|
121
119
|
return unwrappedProperty;
|
|
122
120
|
};
|
|
123
121
|
exports.unwrapPropertyNode = unwrapPropertyNode;
|
|
124
|
-
/** Transforms the AST properties to the format of aeria schema properties */
|
|
125
122
|
const recursivelyUnwrapPropertyNodes = (properties) => {
|
|
126
123
|
return Object.entries(properties).reduce((acc, [key, value]) => {
|
|
127
124
|
if (Array.isArray(value)) {
|
|
@@ -134,9 +131,7 @@ const recursivelyUnwrapPropertyNodes = (properties) => {
|
|
|
134
131
|
}, {});
|
|
135
132
|
};
|
|
136
133
|
exports.recursivelyUnwrapPropertyNodes = recursivelyUnwrapPropertyNodes;
|
|
137
|
-
exports.UnquotedSymbol = Symbol('unquoted');
|
|
138
134
|
const isRecord = (value) => typeof value === 'object';
|
|
139
|
-
/** Assure if specific fields needs to be between quotes or not */
|
|
140
135
|
const stringify = (value, parents = []) => {
|
|
141
136
|
if (Array.isArray(value)) {
|
|
142
137
|
let arrayString = '[\n';
|
|
@@ -172,7 +167,6 @@ const checkQuotes = (parents, value) => {
|
|
|
172
167
|
}
|
|
173
168
|
return (0, exports.stringify)(value, parents);
|
|
174
169
|
};
|
|
175
|
-
/** Used to make the id and the schema name of the collection */
|
|
176
170
|
const resizeFirstChar = (text, capitalize) => {
|
|
177
171
|
if (capitalize === true) {
|
|
178
172
|
return text.charAt(0).toUpperCase() + text.slice(1);
|
package/dist/codegen/utils.mjs
CHANGED
|
@@ -12,6 +12,7 @@ export const DEFAULT_FUNCTIONS = [
|
|
|
12
12
|
"unpaginatedGetAll",
|
|
13
13
|
"upload"
|
|
14
14
|
];
|
|
15
|
+
export const UnquotedSymbol = Symbol("unquoted");
|
|
15
16
|
export const ArraySymbol = Symbol("array");
|
|
16
17
|
export const getExposedFunctions = (astFunctions) => {
|
|
17
18
|
return Object.fromEntries(Object.entries(astFunctions).map(([key, value]) => [
|
|
@@ -115,7 +116,6 @@ export const recursivelyUnwrapPropertyNodes = (properties) => {
|
|
|
115
116
|
return acc;
|
|
116
117
|
}, {});
|
|
117
118
|
};
|
|
118
|
-
export const UnquotedSymbol = Symbol("unquoted");
|
|
119
119
|
const isRecord = (value) => typeof value === "object";
|
|
120
120
|
export const stringify = (value, parents = []) => {
|
|
121
121
|
if (Array.isArray(value)) {
|
package/dist/codegen.js
CHANGED
|
@@ -37,20 +37,6 @@ exports.generateCode = void 0;
|
|
|
37
37
|
const index_js_1 = require("./codegen/index.js");
|
|
38
38
|
const fsPromises = __importStar(require("node:fs/promises"));
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
|
-
/**
|
|
41
|
-
* Maps the path tree into a object with the full paths
|
|
42
|
-
* {
|
|
43
|
-
* folderX: {
|
|
44
|
-
* folderY: {
|
|
45
|
-
* file: ...
|
|
46
|
-
* }
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* turns into
|
|
50
|
-
* {
|
|
51
|
-
* ['outDir/folderX/folderY/file']: ...
|
|
52
|
-
* }
|
|
53
|
-
*/
|
|
54
40
|
const generateFileMap = async (fileTree, outDir = '.') => {
|
|
55
41
|
const mappedPaths = {};
|
|
56
42
|
const mapPathTree = async (tree, previousPath) => {
|
package/dist/parser.js
CHANGED
|
@@ -1227,6 +1227,12 @@ const parse = (tokens) => {
|
|
|
1227
1227
|
if (match(token_js_1.TokenType.LeftParens)) {
|
|
1228
1228
|
term2 = parseCondition(symbols);
|
|
1229
1229
|
}
|
|
1230
|
+
else if (match(token_js_1.TokenType.LeftSquareBracket)) {
|
|
1231
|
+
term2 = parseArray([
|
|
1232
|
+
token_js_1.TokenType.QuotedString,
|
|
1233
|
+
token_js_1.TokenType.Number,
|
|
1234
|
+
]).value;
|
|
1235
|
+
}
|
|
1230
1236
|
else {
|
|
1231
1237
|
term2 = current().value;
|
|
1232
1238
|
advance();
|
package/dist/parser.mjs
CHANGED
|
@@ -1165,6 +1165,11 @@ export const parse = (tokens) => {
|
|
|
1165
1165
|
let term2;
|
|
1166
1166
|
if (match(TokenType.LeftParens)) {
|
|
1167
1167
|
term2 = parseCondition(symbols);
|
|
1168
|
+
} else if (match(TokenType.LeftSquareBracket)) {
|
|
1169
|
+
term2 = parseArray([
|
|
1170
|
+
TokenType.QuotedString,
|
|
1171
|
+
TokenType.Number
|
|
1172
|
+
]).value;
|
|
1168
1173
|
} else {
|
|
1169
1174
|
term2 = current().value;
|
|
1170
1175
|
advance();
|