jitar 0.3.3 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
 
2
2
  # Changelog
3
3
 
4
+ ## 0.3.5 (February 26, 2023)
5
+
6
+ - Bump dependency for the latest version of jitar-reflection.
7
+
8
+ ## 0.3.4 (February 23, 2023)
9
+
10
+ New features:
11
+ - \[[`00a1f4f`](https://github.com/MaskingTechnology/jitar/commit/00a1f4f)] Use the advanced reflection library [basmasking](https://github.com/MaskingTechnology/jitar/pull/168)
12
+
13
+ ## 0.3.3 (February 13, 2023)
14
+
15
+ New features:
16
+ - \[[`18d6a4a`](https://github.com/MaskingTechnology/jitar/commit/18d6a4a)] Extended options for CORS middleware [petermasking](https://github.com/MaskingTechnology/jitar/pull/133)
17
+
4
18
  ## 0.3.2 (February 10, 2023)
5
19
 
6
20
  Fixes:
@@ -1,6 +1,5 @@
1
1
  import * as AccessLevel from '../../core/definitions/AccessLevel.js';
2
2
  import Version from '../../core/Version.js';
3
- import ModuleLoader from '../utils/ModuleLoader.js';
4
3
  import ModuleAnalyser from '../utils/ModuleAnalyser.js';
5
4
  import SourceAppender from './SourceAppender.js';
6
5
  import ImportRewriter from './ImportRewriter.js';
@@ -14,9 +13,11 @@ import SegmentFileNotLoaded from './errors/SegmentFileNotLoaded.js';
14
13
  import SegmentModuleNotLoaded from './errors/SegmentModuleNotLoaded.js';
15
14
  import MissingModuleExport from './errors/MissingModuleExport.js';
16
15
  import InvalidSegmentFilename from './errors/InvalidSegmentFilename.js';
16
+ import { Reflector } from 'jitar-reflection';
17
17
  const IGNORED_SOURCE_FILES = ['.min.js'];
18
18
  const DEFAULT_ACCESS_LEVEL = AccessLevel.PRIVATE;
19
19
  const DEFAULT_VERSION_NUMBER = Version.DEFAULT.toString();
20
+ const reflector = new Reflector();
20
21
  export default class CacheBuilder {
21
22
  #sourceManager;
22
23
  #cacheManager;
@@ -81,7 +82,7 @@ export default class CacheBuilder {
81
82
  const moduleName = this.#extractModuleName(absoluteLocation);
82
83
  const implementations = new Map();
83
84
  for (const [importKey, properties] of Object.entries(imports)) {
84
- const executable = exports[importKey];
85
+ const executable = exports.getExported(importKey);
85
86
  if (executable === undefined) {
86
87
  throw new MissingModuleExport(moduleName, importKey);
87
88
  }
@@ -128,12 +129,8 @@ export default class CacheBuilder {
128
129
  return new ApplicationModule(relativeLocation, classes, functions);
129
130
  }
130
131
  async #loadModule(filename) {
131
- try {
132
- return await ModuleLoader.load(filename);
133
- }
134
- catch (error) {
135
- return undefined;
136
- }
132
+ const code = await this.#sourceManager.getContent(filename);
133
+ return reflector.parse(code.toString());
137
134
  }
138
135
  async #buildSegmentCache(segments) {
139
136
  const promises = segments.map(async (segment) => this.#buildSegmentModuleCache(segment));
@@ -1,6 +1,6 @@
1
1
  import * as AccessLevel from '../../core/definitions/AccessLevel.js';
2
- import ReflectionHelper from '../../core/reflection/ReflectionHelper.js';
3
2
  import * as Keywords from './definitions/Keywords.js';
3
+ import { ReflectionField } from 'jitar-reflection';
4
4
  export default class RemoteBuilder {
5
5
  static build(module) {
6
6
  let code = this.#createRemoteImports();
@@ -17,7 +17,7 @@ export default class RemoteBuilder {
17
17
  return `import { runProcedure } from "/jitar/hooks.js";\n`;
18
18
  }
19
19
  static #createRemoteCode(implementation, asDefault) {
20
- const parameters = ReflectionHelper.getFunctionParameters(implementation.executable);
20
+ const parameters = implementation.executable.parameters.filter(parameter => parameter instanceof ReflectionField);
21
21
  const parameterNames = parameters.map(parameter => parameter.name);
22
22
  const procedureName = implementation.executable.name;
23
23
  const procedureFqn = implementation.fqn;
@@ -13,7 +13,7 @@ export default class SourceAppender {
13
13
  const names = [];
14
14
  for (const key of classes.keys()) {
15
15
  const clazz = classes.get(key);
16
- if (clazz.name === '') {
16
+ if (clazz === undefined) {
17
17
  continue;
18
18
  }
19
19
  if (key !== Keywords.DEFAULT && key !== clazz.name) {
@@ -1,9 +1,10 @@
1
+ import { ReflectionClass, ReflectionFunction } from 'jitar-reflection';
1
2
  export default class ApplicationModule {
2
3
  #private;
3
- constructor(filename: string, classes: Map<string, Function>, functions: Map<string, Function>);
4
+ constructor(filename: string, classes: Map<string, ReflectionClass>, functions: Map<string, ReflectionFunction>);
4
5
  get filename(): string;
5
- get classes(): Map<string, Function>;
6
- get functions(): Map<string, Function>;
6
+ get classes(): Map<string, ReflectionClass>;
7
+ get functions(): Map<string, ReflectionFunction>;
7
8
  hasClasses(): boolean;
8
9
  hasFunctions(): boolean;
9
10
  }
@@ -1,12 +1,12 @@
1
- import Component from '../../../core/types/Component.js';
1
+ import { ReflectionFunction } from 'jitar-reflection';
2
2
  export default class Implementation {
3
3
  #private;
4
- constructor(module: string, name: string, access: string, version: string, executable: Component);
4
+ constructor(module: string, name: string, access: string, version: string, executable: ReflectionFunction);
5
5
  get id(): number;
6
6
  get module(): string;
7
7
  get name(): string;
8
8
  get fqn(): string;
9
9
  get access(): string;
10
10
  get version(): string;
11
- get executable(): Component;
11
+ get executable(): ReflectionFunction;
12
12
  }
@@ -1,10 +1,10 @@
1
- import Module from '../../../core/types/Module.js';
2
1
  import Implementation from './Implementation.js';
2
+ import { ReflectionModule } from 'jitar-reflection';
3
3
  export default class SegmentModule {
4
4
  #private;
5
- constructor(filename: string, exports: Module, implementations: Map<string, Implementation>);
5
+ constructor(filename: string, exports: ReflectionModule, implementations: Map<string, Implementation>);
6
6
  get filename(): string;
7
- get exports(): import("../../../core/types/FlexObject.js").default;
7
+ get exports(): ReflectionModule;
8
8
  get implementations(): Map<string, Implementation>;
9
9
  getImportKeys(): string[];
10
10
  }
@@ -1,7 +1,7 @@
1
- import Module from '../../core/types/Module.js';
1
+ import { ReflectionModule, ReflectionFunction, ReflectionField, ReflectionClass } from 'jitar-reflection';
2
2
  export default class ModuleAnalyser {
3
3
  #private;
4
- static filterObjects(module: Module): Map<string, Object>;
5
- static filterFunctions(module: Module): Map<string, Function>;
6
- static filterClasses(module: Module): Map<string, Function>;
4
+ static filterFields(module: ReflectionModule): Map<string, ReflectionField>;
5
+ static filterFunctions(module: ReflectionModule): Map<string, ReflectionFunction>;
6
+ static filterClasses(module: ReflectionModule): Map<string, ReflectionClass>;
7
7
  }
@@ -1,32 +1,21 @@
1
+ import { ReflectionFunction, ReflectionField, ReflectionClass } from 'jitar-reflection';
1
2
  export default class ModuleAnalyser {
2
- static filterObjects(module) {
3
- return this.#filterexported(module, Object);
3
+ static filterFields(module) {
4
+ return this.#filterexported(module, ReflectionField);
4
5
  }
5
6
  static filterFunctions(module) {
6
- const functions = this.#filterexported(module, Function);
7
- return this.#filterFunctionTypes(functions, false);
7
+ return this.#filterexported(module, ReflectionFunction);
8
8
  }
9
9
  static filterClasses(module) {
10
- const functions = this.#filterexported(module, Function);
11
- return this.#filterFunctionTypes(functions, true);
10
+ return this.#filterexported(module, ReflectionClass);
12
11
  }
13
12
  static #filterexported(module, type) {
14
- const keys = Object.keys(module);
13
+ const keys = [...module.exported.keys()];
15
14
  const filtered = new Map();
16
15
  for (const key of keys) {
17
- const exported = module[key];
18
- if (exported instanceof type) {
19
- filtered.set(key, exported);
20
- }
21
- }
22
- return filtered;
23
- }
24
- static #filterFunctionTypes(functions, filterClasses) {
25
- const filtered = new Map();
26
- for (const [key, value] of functions) {
27
- const code = value.toString();
28
- if (code.startsWith('class') === filterClasses) {
29
- filtered.set(key, value);
16
+ const member = module.getExported(key);
17
+ if (member?.constructor.name === type.name) {
18
+ filtered.set(key, member);
30
19
  }
31
20
  }
32
21
  return filtered;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jitar",
3
- "version": "0.3.3",
3
+ "version": "0.3.6",
4
4
  "description": "Distributed runtime for JavaScript and TypeScript to chop monolithic applications into micros.",
5
5
  "author": "Masking Technology <info@masking.tech> (https://jitar.dev)",
6
6
  "license": "MIT",
@@ -13,20 +13,15 @@
13
13
  "./hooks.js": "./dist/hooks.js"
14
14
  },
15
15
  "scripts": {
16
- "test": "jest",
17
- "test-coverage": "jest --coverage",
16
+ "test": "vitest run",
17
+ "test-coverage": "vitest run --coverage",
18
18
  "lint": "eslint . --ext .ts",
19
19
  "build": "tsc -p tsconfig.json",
20
20
  "clean": "rm -rf dist build",
21
21
  "release": "npm run clean && npm run build && npm publish"
22
22
  },
23
- "devDependencies": {
24
- "@types/jest": "^29.4.0",
25
- "@typescript-eslint/eslint-plugin": "^5.51.0",
26
- "@typescript-eslint/parser": "^5.51.0",
27
- "eslint": "^8.34.0",
28
- "jest": "^29.4.2",
29
- "ts-jest": "^29.0.5"
23
+ "dependencies": {
24
+ "jitar-reflection": "^0.3.6"
30
25
  },
31
26
  "engines": {
32
27
  "node": ">=18.7"
@@ -48,6 +43,5 @@
48
43
  "monolith",
49
44
  "full stack",
50
45
  "web applications"
51
- ],
52
- "gitHead": "26a6275ac9afbc971ca891f7dcae739a7f317cd4"
53
- }
46
+ ]
47
+ }
package/LICENCE DELETED
@@ -1,23 +0,0 @@
1
-
2
- (The MIT License)
3
-
4
- Copyright (c) 2023 Masking Technology B.V. <https://masking.tech>
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining
7
- a copy of this software and associated documentation files (the
8
- 'Software'), to deal in the Software without restriction, including
9
- without limitation the rights to use, copy, modify, merge, publish,
10
- distribute, sublicense, and/or sell copies of the Software, and to
11
- permit persons to whom the Software is furnished to do so, subject to
12
- the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.