@aeriajs/compiler 0.0.6 → 0.0.7

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.
@@ -9,7 +9,7 @@ const initialImportedFunctions = [
9
9
  const generateJSCollections = (ast) => {
10
10
  let javascriptCode = '';
11
11
  const importsResult = (0, utils_js_1.makeASTImports)(ast, {
12
- [utils_js_1.aeriaPackageName]: new Set(initialImportedFunctions),
12
+ [utils_js_1.PACKAGE_NAME]: new Set(initialImportedFunctions),
13
13
  });
14
14
  javascriptCode += importsResult.code + '\n\n';
15
15
  javascriptCode += makeJSCollections(ast, importsResult.modifiedSymbols) + '\n\n';
@@ -85,7 +85,7 @@ const makeJSCollectionSchema = (collectionNode, collectionId) => {
85
85
  return (0, utils_js_1.stringify)(collectionSchema);
86
86
  };
87
87
  const makeJSFunctions = (functions) => {
88
- return Object.entries(functions).map(([key, _value]) => utils_js_1.defaultFunctions.includes(key)
88
+ return Object.entries(functions).map(([key, _value]) => utils_js_1.DEFAULT_FUNCTIONS.includes(key)
89
89
  ? key
90
90
  : `${key}: () => { throw new Error('Function not implemented') }`).join(', ');
91
91
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- import { makeASTImports, getProperties, stringify, aeriaPackageName, getExtendName, getCollectionId, UnquotedSymbol, defaultFunctions, getExposedFunctions } from "./utils.mjs";
2
+ import { makeASTImports, getProperties, stringify, getExtendName, getCollectionId, UnquotedSymbol, getExposedFunctions, PACKAGE_NAME, DEFAULT_FUNCTIONS } from "./utils.mjs";
3
3
  const initialImportedFunctions = [
4
4
  "extendCollection",
5
5
  "defineCollection"
@@ -7,7 +7,7 @@ const initialImportedFunctions = [
7
7
  export const generateJSCollections = (ast) => {
8
8
  let javascriptCode = "";
9
9
  const importsResult = makeASTImports(ast, {
10
- [aeriaPackageName]: new Set(initialImportedFunctions)
10
+ [PACKAGE_NAME]: new Set(initialImportedFunctions)
11
11
  });
12
12
  javascriptCode += importsResult.code + "\n\n";
13
13
  javascriptCode += makeJSCollections(ast, importsResult.modifiedSymbols) + "\n\n";
@@ -78,5 +78,5 @@ const makeJSCollectionSchema = (collectionNode, collectionId) => {
78
78
  return stringify(collectionSchema);
79
79
  };
80
80
  const makeJSFunctions = (functions) => {
81
- return Object.entries(functions).map(([key, _value]) => defaultFunctions.includes(key) ? key : `${key}: () => { throw new Error('Function not implemented') }`).join(", ");
81
+ return Object.entries(functions).map(([key, _value]) => DEFAULT_FUNCTIONS.includes(key) ? key : `${key}: () => { throw new Error('Function not implemented') }`).join(", ");
82
82
  };
@@ -10,7 +10,7 @@ const initialImportedTypes = [
10
10
  ];
11
11
  const generateTSCollections = (ast) => {
12
12
  let code = '';
13
- code += `import type { ${initialImportedTypes.join(', ')} } from '${utils_js_1.aeriaPackageName}'\n`; //Used types
13
+ code += `import type { ${initialImportedTypes.join(', ')} } from '${utils_js_1.PACKAGE_NAME}'\n`; //Used types
14
14
  const importsResult = (0, utils_js_1.makeASTImports)(ast);
15
15
  code += importsResult.code + '\n\n';
16
16
  code += makeTSCollections(ast, importsResult.modifiedSymbols) + '\n';
@@ -98,7 +98,7 @@ const makeTSCollectionSchema = (collectionNode, collectionId) => {
98
98
  const makeTSFunctions = (functions) => {
99
99
  return Object.keys(functions).reduce((acc, key) => {
100
100
  acc[key] = {
101
- [utils_js_1.UnquotedSymbol]: utils_js_1.defaultFunctions.includes(key)
101
+ [utils_js_1.UnquotedSymbol]: utils_js_1.DEFAULT_FUNCTIONS.includes(key)
102
102
  ? `typeof ${key}`
103
103
  : '() => never',
104
104
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- import { getProperties, stringify, makeASTImports, resizeFirstChar, aeriaPackageName, getCollectionId, UnquotedSymbol, defaultFunctions, getExposedFunctions } from "./utils.mjs";
2
+ import { getProperties, stringify, makeASTImports, resizeFirstChar, getCollectionId, UnquotedSymbol, getExposedFunctions, PACKAGE_NAME, DEFAULT_FUNCTIONS } from "./utils.mjs";
3
3
  const initialImportedTypes = [
4
4
  "Collection",
5
5
  "SchemaWithId",
@@ -8,7 +8,7 @@ const initialImportedTypes = [
8
8
  ];
9
9
  export const generateTSCollections = (ast) => {
10
10
  let code = "";
11
- code += `import type { ${initialImportedTypes.join(", ")} } from '${aeriaPackageName}'
11
+ code += `import type { ${initialImportedTypes.join(", ")} } from '${PACKAGE_NAME}'
12
12
  `;
13
13
  const importsResult = makeASTImports(ast);
14
14
  code += importsResult.code + "\n\n";
@@ -92,7 +92,7 @@ const makeTSCollectionSchema = (collectionNode, collectionId) => {
92
92
  const makeTSFunctions = (functions) => {
93
93
  return Object.keys(functions).reduce((acc, key) => {
94
94
  acc[key] = {
95
- [UnquotedSymbol]: defaultFunctions.includes(key) ? `typeof ${key}` : "() => never"
95
+ [UnquotedSymbol]: DEFAULT_FUNCTIONS.includes(key) ? `typeof ${key}` : "() => never"
96
96
  };
97
97
  return acc;
98
98
  }, {});
@@ -1,7 +1,7 @@
1
- import type * as AST from '../ast';
1
+ import type * as AST from '../ast.js';
2
2
  import type { Property } from '@aeriajs/types';
3
- export declare const aeriaPackageName = "aeria";
4
- export declare const defaultFunctions: string[];
3
+ export declare const PACKAGE_NAME = "aeria";
4
+ export declare const DEFAULT_FUNCTIONS: string[];
5
5
  export declare const ArraySymbol: unique symbol;
6
6
  export declare const getExposedFunctions: (astFunctions: NonNullable<AST.CollectionNode["functions"]>) => {
7
7
  [k: string]: import("@aeriajs/types").AccessCondition;
@@ -1,9 +1,17 @@
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.defaultFunctions = exports.aeriaPackageName = void 0;
4
- const core_1 = require("@aeriajs/core");
5
- exports.aeriaPackageName = 'aeria';
6
- exports.defaultFunctions = Object.keys(core_1.functions);
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;
4
+ exports.PACKAGE_NAME = 'aeria';
5
+ exports.DEFAULT_FUNCTIONS = [
6
+ 'count',
7
+ 'get',
8
+ 'getAll',
9
+ 'insert',
10
+ 'upload',
11
+ 'remove',
12
+ 'removeAll',
13
+ 'removeFile',
14
+ ];
7
15
  exports.ArraySymbol = Symbol('array');
8
16
  const getExposedFunctions = (astFunctions) => {
9
17
  return Object.fromEntries(Object.entries(astFunctions)
@@ -29,13 +37,13 @@ const makeASTImports = (ast, initialImports) => {
29
37
  imports[node.extends.packageName].add(`${node.extends.symbolName} as ${modifiedSymbol}`);
30
38
  }
31
39
  if (node.functions) {
32
- const functionsToImport = Object.keys(node.functions).filter((key) => exports.defaultFunctions.includes(key));
40
+ const functionsToImport = Object.keys(node.functions).filter((key) => exports.DEFAULT_FUNCTIONS.includes(key));
33
41
  if (functionsToImport.length > 0) {
34
- if (!(exports.aeriaPackageName in imports)) {
35
- imports[exports.aeriaPackageName] = new Set();
42
+ if (!(exports.PACKAGE_NAME in imports)) {
43
+ imports[exports.PACKAGE_NAME] = new Set();
36
44
  }
37
45
  for (const key of functionsToImport) {
38
- imports[exports.aeriaPackageName].add(key);
46
+ imports[exports.PACKAGE_NAME].add(key);
39
47
  }
40
48
  }
41
49
  }
@@ -1,7 +1,15 @@
1
1
  "use strict";
2
- import { functions as aeriaFunctions } from "@aeriajs/core";
3
- export const aeriaPackageName = "aeria";
4
- export const defaultFunctions = Object.keys(aeriaFunctions);
2
+ export const PACKAGE_NAME = "aeria";
3
+ export const DEFAULT_FUNCTIONS = [
4
+ "count",
5
+ "get",
6
+ "getAll",
7
+ "insert",
8
+ "upload",
9
+ "remove",
10
+ "removeAll",
11
+ "removeFile"
12
+ ];
5
13
  export const ArraySymbol = Symbol("array");
6
14
  export const getExposedFunctions = (astFunctions) => {
7
15
  return Object.fromEntries(Object.entries(astFunctions).map(([key, value]) => [
@@ -22,13 +30,13 @@ export const makeASTImports = (ast, initialImports) => {
22
30
  imports[node.extends.packageName].add(`${node.extends.symbolName} as ${modifiedSymbol}`);
23
31
  }
24
32
  if (node.functions) {
25
- const functionsToImport = Object.keys(node.functions).filter((key) => defaultFunctions.includes(key));
33
+ const functionsToImport = Object.keys(node.functions).filter((key) => DEFAULT_FUNCTIONS.includes(key));
26
34
  if (functionsToImport.length > 0) {
27
- if (!(aeriaPackageName in imports)) {
28
- imports[aeriaPackageName] = /* @__PURE__ */ new Set();
35
+ if (!(PACKAGE_NAME in imports)) {
36
+ imports[PACKAGE_NAME] = /* @__PURE__ */ new Set();
29
37
  }
30
38
  for (const key of functionsToImport) {
31
- imports[aeriaPackageName].add(key);
39
+ imports[PACKAGE_NAME].add(key);
32
40
  }
33
41
  }
34
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/compiler",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",