Comparing version 3.0.0 to 3.0.1
@@ -94,6 +94,3 @@ 'use strict'; | ||
const { status, port, exclusive } = msg; | ||
if (status === 'done') { | ||
app.pool.release(worker); | ||
return; | ||
} | ||
if (status === 'done') return void app.pool.release(worker); | ||
const promisedThread = exclusive ? app.pool.capture() : app.pool.next(); | ||
@@ -100,0 +97,0 @@ const next = await promisedThread.catch(() => { |
'use strict'; | ||
const { node, npm, metarhia, wt } = require('./dependencies.js'); | ||
const { node, npm, metarhia, wt } = require('./deps.js'); | ||
const { MessageChannel, parentPort, threadId, workerData } = wt; | ||
const { Error, DomainError } = metarhia.metautil; | ||
const { Interfaces } = require('./interfaces.js'); | ||
const { Modules } = require('./modules.js'); | ||
const { Resources } = require('./resources.js'); | ||
const { Certificates } = require('./certificates.js'); | ||
const { Api } = require('./api.js'); | ||
const { Place } = require('./place.js'); | ||
const { Static } = require('./static.js'); | ||
const { Cert } = require('./cert.js'); | ||
const { Schemas } = require('./schemas.js'); | ||
@@ -27,10 +27,10 @@ const scheduler = require('./scheduler.js'); | ||
class UserApplication extends node.events.EventEmitter { | ||
const UserApplication = class Application extends node.events.EventEmitter { | ||
constructor(app, data) { | ||
super(); | ||
Object.assign(this, data); | ||
this.introspect = async (interfaces) => app.introspect(interfaces); | ||
this.introspect = async (units) => app.introspect(units); | ||
this.invoke = invoke; | ||
} | ||
} | ||
}; | ||
@@ -52,13 +52,12 @@ const { COMMON_CONTEXT } = metarhia.metavm; | ||
this.schemas = new Schemas('schemas', this); | ||
this.static = new Resources('static', this); | ||
this.cert = new Certificates('cert', this, { ext: ['pem', 'domains'] }); | ||
this.resources = new Resources('resources', this); | ||
this.api = new Interfaces('api', this); | ||
this.lib = new Modules('lib', this); | ||
this.db = new Modules('db', this); | ||
this.bus = new Modules('bus', this); | ||
this.domain = new Modules('domain', this); | ||
this.static = new Static('static', this); | ||
this.cert = new Cert('cert', this, { ext: ['pem', 'domains'] }); | ||
this.resources = new Static('resources', this); | ||
this.api = new Api('api', this); | ||
this.lib = new Place('lib', this); | ||
this.db = new Place('db', this); | ||
this.bus = new Place('bus', this); | ||
this.domain = new Place('domain', this); | ||
this.starts = []; | ||
this.Application = Application; | ||
this.config = null; | ||
@@ -150,7 +149,7 @@ this.logger = null; | ||
getMethod(iname, ver, methodName) { | ||
const iface = this.api.collection[iname]; | ||
if (!iface) return null; | ||
const version = ver === '*' ? iface.default : parseInt(ver, 10); | ||
const methods = iface[version.toString()]; | ||
getMethod(name, ver, methodName) { | ||
const unit = this.api.collection[name]; | ||
if (!unit) return null; | ||
const version = ver === '*' ? unit.default : parseInt(ver, 10); | ||
const methods = unit[version.toString()]; | ||
if (!methods) return null; | ||
@@ -162,6 +161,6 @@ const proc = methods[methodName]; | ||
getHook(iname) { | ||
const iface = this.api.collection[iname]; | ||
if (!iface) return null; | ||
const hook = iface[iface.default]; | ||
getHook(name) { | ||
const unit = this.api.collection[name]; | ||
if (!unit) return null; | ||
const hook = unit[unit.default]; | ||
if (!hook) return null; | ||
@@ -189,6 +188,3 @@ return hook.router; | ||
if (error) return; | ||
if (stat.isDirectory()) { | ||
this[place].load(filePath); | ||
return; | ||
} | ||
if (stat.isDirectory()) return void this[place].load(filePath); | ||
if (threadId === 1) this.console.debug('Reload: /' + relPath); | ||
@@ -215,10 +211,10 @@ this[place].change(filePath); | ||
introspect(interfaces) { | ||
introspect(units) { | ||
const intro = {}; | ||
for (const interfaceName of interfaces) { | ||
const [iname, ver = '*'] = interfaceName.split('.'); | ||
const iface = this.api.collection[iname]; | ||
if (!iface) continue; | ||
const version = ver === '*' ? iface.default : parseInt(ver, 10); | ||
intro[iname] = this.api.signatures[iname + '.' + version]; | ||
for (const unitName of units) { | ||
const [name, ver = '*'] = unitName.split('.'); | ||
const unit = this.api.collection[name]; | ||
if (!unit) continue; | ||
const version = ver === '*' ? unit.default : parseInt(ver, 10); | ||
intro[name] = this.api.signatures[name + '.' + version]; | ||
} | ||
@@ -225,0 +221,0 @@ return intro; |
'use strict'; | ||
const { metarhia } = require('./dependencies.js'); | ||
const { metarhia } = require('./deps.js'); | ||
@@ -5,0 +5,0 @@ const accounts = new Map(); |
'use strict'; | ||
const { node } = require('./dependencies.js'); | ||
const { node, metarhia } = require('./deps.js'); | ||
@@ -13,2 +13,3 @@ class Cache { | ||
async load(targetPath = this.path) { | ||
await metarhia.metautil.ensureDirectory(this.path); | ||
this.application.watcher.watch(targetPath); | ||
@@ -15,0 +16,0 @@ try { |
'use strict'; | ||
const { node, metarhia, wt } = require('./dependencies.js'); | ||
const { node, metarhia, wt } = require('./deps.js'); | ||
@@ -159,6 +159,3 @@ class Planner { | ||
async execute(task, once = false) { | ||
if (task.executing) { | ||
this.fail(task, 'Already started task'); | ||
return; | ||
} | ||
if (task.executing) return void this.fail(task, 'Already started task'); | ||
task.lastStart = Date.now(); | ||
@@ -201,4 +198,3 @@ task.executing = true; | ||
const error = new Error('No application for task: ' + data); | ||
this.console.error(error); | ||
return; | ||
return void this.console.error(error); | ||
} | ||
@@ -205,0 +201,0 @@ app.pool.next().then( |
'use strict'; | ||
const { metarhia } = require('./dependencies.js'); | ||
const { metarhia } = require('./deps.js'); | ||
const { Error, DomainError } = metarhia.metautil; | ||
@@ -5,0 +5,0 @@ |
'use strict'; | ||
const { wt } = require('./dependencies.js'); | ||
const { wt } = require('./deps.js'); | ||
@@ -5,0 +5,0 @@ const add = async (task) => { |
'use strict'; | ||
const { node, metarhia } = require('./dependencies.js'); | ||
const { node, metarhia } = require('./deps.js'); | ||
const { Cache } = require('./cache.js'); | ||
@@ -5,0 +5,0 @@ |
'use strict'; | ||
const { node, metarhia, notLoaded, wt } = require('./dependencies.js'); | ||
const { node, metarhia, notLoaded, wt } = require('./deps.js'); | ||
const application = require('./application.js'); | ||
@@ -58,4 +58,3 @@ | ||
const error = new Error('Handler not found'); | ||
port.postMessage({ name: 'error', error }); | ||
return; | ||
return void port.postMessage({ name: 'error', error }); | ||
} | ||
@@ -62,0 +61,0 @@ const msg = { name: 'invoke', status: 'done' }; |
{ | ||
"name": "impress", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -65,7 +65,7 @@ "description": "Enterprise application server for Node.js", | ||
"dependencies": { | ||
"metacom": "^3.0.0", | ||
"metacom": "^3.0.1", | ||
"metaconfiguration": "^2.1.11", | ||
"metalog": "^3.1.11", | ||
"metaschema": "^2.1.4", | ||
"metautil": "^3.10.0", | ||
"metalog": "^3.1.12", | ||
"metaschema": "^2.1.5", | ||
"metautil": "^3.11.0", | ||
"metavm": "^1.2.4", | ||
@@ -75,13 +75,13 @@ "metawatch": "^1.1.1" | ||
"devDependencies": { | ||
"@types/node": "^20.3.2", | ||
"@types/node": "^20.4.4", | ||
"@types/ws": "^8.5.5", | ||
"eslint": "^8.43.0", | ||
"eslint-config-metarhia": "^8.1.0", | ||
"eslint": "^8.45.0", | ||
"eslint-config-metarhia": "^8.2.1", | ||
"eslint-config-prettier": "^8.7.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"metatests": "^0.8.2", | ||
"prettier": "^2.8.4", | ||
"prettier": "^3.0.0", | ||
"typescript": "^5.1.6" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { EventEmitter, NodeJS } from 'node:events'; | ||
import { EventEmitter } from 'node:events'; | ||
@@ -21,19 +21,26 @@ export interface Task { | ||
export interface Application extends NodeJS.EventEmitter { | ||
worker: object; | ||
server: object; | ||
auth: object; | ||
resources: Map<string, Buffer>; | ||
introspect: () => Promise<any>; | ||
invoke: (target: InvokeTarget) => Promise<any>; | ||
scheduler: Scheduler; | ||
export interface Cache { | ||
get(name: string): unknown; | ||
} | ||
on(event: 'loading', listener: (...args: any[]) => void): this; | ||
once(event: 'loading', listener: (...args: any[]) => void): this; | ||
on(event: 'loaded', listener: (...args: any[]) => void): this; | ||
once(event: 'loaded', listener: (...args: any[]) => void): this; | ||
on(event: 'started', listener: (...args: any[]) => void): this; | ||
once(event: 'started', listener: (...args: any[]) => void): this; | ||
on(event: 'initialized', listener: (...args: any[]) => void): this; | ||
once(event: 'initialized', listener: (...args: any[]) => void): this; | ||
export interface Listener { | ||
(...args: Array<unknown>): void; | ||
} | ||
export interface Application extends EventEmitter { | ||
worker: { id: string }; | ||
server: { host: string; port: number; protocol: string }; | ||
resources: Cache; | ||
schemas: Cache; | ||
scheduler: Scheduler; | ||
introspect: () => Promise<object>; | ||
invoke: (target: InvokeTarget) => Promise<unknown>; | ||
on(event: 'loading', listener: Listener): this; | ||
once(event: 'loading', listener: Listener): this; | ||
on(event: 'loaded', listener: Listener): this; | ||
once(event: 'loaded', listener: Listener): this; | ||
on(event: 'started', listener: Listener): this; | ||
once(event: 'started', listener: Listener): this; | ||
on(event: 'initialized', listener: Listener): this; | ||
once(event: 'initialized', listener: Listener): this; | ||
} |
@@ -42,2 +42,3 @@ import { LogConfig, ScaleConfig, ServerConfig, SessionsConfig } from './config'; | ||
import * as _metaschema from 'metaschema'; | ||
import * as _metaconfiguration from 'metaconfiguration'; | ||
@@ -63,2 +64,3 @@ declare global { | ||
const metaschema: typeof _metaschema; | ||
const metaconfiguration: typeof _metaconfiguration; | ||
} | ||
@@ -65,0 +67,0 @@ |
@@ -21,2 +21,3 @@ import { Schema } from 'metaschema'; | ||
script: Function; | ||
methodName: string; | ||
application: Application; | ||
@@ -26,2 +27,3 @@ method?: AsyncFunction; | ||
returns?: Schema; | ||
errors?: Record<string, string>; | ||
semaphore?: Semaphore; | ||
@@ -28,0 +30,0 @@ caption?: string; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63430
1657
Updatedmetacom@^3.0.1
Updatedmetalog@^3.1.12
Updatedmetaschema@^2.1.5
Updatedmetautil@^3.11.0