Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nmtjs/application

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nmtjs/application - npm Package Compare versions

Comparing version 0.3.10 to 0.3.11

2

dist/lib/api.js

@@ -149,3 +149,3 @@ import { ErrorCode } from '@nmtjs/common';

if (!compiled) throw new Error('Compiled schema not found');
return compiled[method](payload);
return compiled[`${method}Safe`](payload);
}

@@ -152,0 +152,0 @@ }

@@ -18,2 +18,3 @@ import { Api } from "./api.js";

registry;
internalContainer;
container;

@@ -35,8 +36,9 @@ eventManager;

this.format = new Format(this.options.api.formats);
const container = new Container(this);
container.provide(builtin.logger, this.logger);
container.provide(builtin.workerType, this.options.type);
container.provide(builtin.eventManager, this.eventManager);
container.provide(builtin.execute, this.execute.bind(this));
this.container = container.createScope(Scope.Global);
this.internalContainer = new Container(this);
this.internalContainer.provide(builtin.logger, this.logger);
this.internalContainer.provide(builtin.workerType, this.options.type);
this.internalContainer.provide(builtin.eventManager, this.eventManager);
this.internalContainer.provide(builtin.execute, this.execute.bind(this));
this.internalContainer.provide(builtin.taskSignal, new AbortController().signal);
this.container = this.internalContainer.createScope(Scope.Global);
this.api = new Api(this, this.options.api);

@@ -43,0 +45,0 @@ this.taskRunner = new TaskRunner(this, this.options.tasks);

@@ -28,3 +28,3 @@ import { randomUUID } from 'node:crypto';

if (schema) {
const result = schema.encode(payload);
const result = schema.encodeSafe(payload);
if (!result.success) {

@@ -31,0 +31,0 @@ throw new Error('Failed to encode payload', {

@@ -24,13 +24,13 @@ export var Scope;

})(WorkerType || (WorkerType = {}));
export const OptionalDependencyKey = Symbol('OptionalDependencyKey');
export const InjectableKey = Symbol('InjectableKey');
export const LazyInjectableKey = Symbol('LazyInjectableKey');
export const ValueInjectableKey = Symbol('ValueInjectableKey');
export const FactoryInjectableKey = Symbol('FactoryInjectableKey');
export const ProviderKey = Symbol('ProviderKey');
export const ProcedureKey = Symbol('ProcedureKey');
export const ProcedureSubscriptionKey = Symbol('ProcedureSubscriptionKey');
export const ProcedureMetadataKey = Symbol('ProcedureMetadataKey');
export const ServiceKey = Symbol('ServiceKey');
export const TaskKey = Symbol('TaskKey');
export const SubscriptionResponseKey = Symbol('SubscriptionResponseKey');
export const OptionalDependencyKey = Symbol.for('neemata:OptionalDependencyKey');
export const InjectableKey = Symbol.for('neemata:InjectableKey');
export const LazyInjectableKey = Symbol.for('neemata:LazyInjectableKey');
export const ValueInjectableKey = Symbol.for('neemata:ValueInjectableKey');
export const FactoryInjectableKey = Symbol.for('neemata:FactoryInjectableKey');
export const ProviderKey = Symbol.for('neemata:ProviderKey');
export const ProcedureKey = Symbol.for('neemata:ProcedureKey');
export const ProcedureSubscriptionKey = Symbol.for('neemata:ProcedureSubscriptionKey');
export const ProcedureMetadataKey = Symbol.for('neemata:ProcedureMetadataKey');
export const ServiceKey = Symbol.for('neemata:ServiceKey');
export const TaskKey = Symbol.for('neemata:TaskKey');
export const SubscriptionResponseKey = Symbol.for('neemata:SubscriptionResponseKey');
import { builtin } from "./common.js";
import { Hook, TaskKey } from "./constants.js";
import { Hook, Scope, TaskKey } from "./constants.js";
import { createFuture, defer, noop, onAbort } from "./utils/functions.js";

@@ -10,3 +10,3 @@ export function createTask(name, paramsOrHandler) {

const handler = params.handler;
const parser = params.parser ?? notImplemented(name, 'parser');
const parser = params.parser;
return {

@@ -36,3 +36,3 @@ name,

const { dependencies, handler } = task;
const container = this.application.container.createScope(this.application.container.scope);
const container = this.application.container.createScope(Scope.Global);
container.provide(builtin.taskSignal, ac.signal);

@@ -72,4 +72,1 @@ const context = await container.createContext(dependencies);

}
const notImplemented = (taskName, fnType)=>()=>{
throw new Error(`Task [${taskName}] ${fnType} is not implemented`);
};

@@ -228,6 +228,6 @@ import { ErrorCode } from '@nmtjs/common'

context?: any,
): ReturnType<Compiled['decode' | 'encode']> {
): ReturnType<Compiled['decodeSafe' | 'encodeSafe']> {
const compiled = this.application.registry.schemas.get(schema)
if (!compiled) throw new Error('Compiled schema not found')
return compiled[method](payload)
return compiled[`${method}Safe`](payload)
}

@@ -234,0 +234,0 @@ }

@@ -38,2 +38,3 @@ import type { BaseServerFormat } from '@nmtjs/common'

readonly registry: Registry
readonly internalContainer: Container
readonly container: Container

@@ -56,13 +57,17 @@ readonly eventManager: EventManager

// create unexposed container for internal injectables, which never gets disposed
const container = new Container(this)
// create unexposed container for builtin injectables, which never gets disposed
this.internalContainer = new Container(this)
container.provide(builtin.logger, this.logger)
container.provide(builtin.workerType, this.options.type)
container.provide(builtin.eventManager, this.eventManager)
container.provide(builtin.execute, this.execute.bind(this))
this.internalContainer.provide(builtin.logger, this.logger)
this.internalContainer.provide(builtin.workerType, this.options.type)
this.internalContainer.provide(builtin.eventManager, this.eventManager)
this.internalContainer.provide(builtin.execute, this.execute.bind(this))
this.internalContainer.provide(
builtin.taskSignal,
new AbortController().signal,
) // this will be replaced in task execution
// create a global container for rest of the application
// including transports, extensions, etc.
this.container = container.createScope(Scope.Global)
this.container = this.internalContainer.createScope(Scope.Global)

@@ -69,0 +74,0 @@ this.api = new Api(this, this.options.api)

@@ -68,3 +68,3 @@ import { randomUUID } from 'node:crypto'

if (schema) {
const result = schema.encode(payload)
const result = schema.encodeSafe(payload)
if (!result.success) {

@@ -71,0 +71,0 @@ throw new Error('Failed to encode payload', { cause: result.error })

@@ -24,46 +24,50 @@ export enum Scope {

export const OptionalDependencyKey: unique symbol = Symbol(
'OptionalDependencyKey',
export const OptionalDependencyKey: unique symbol = Symbol.for(
'neemata:OptionalDependencyKey',
)
export type OptionalDependencyKey = typeof OptionalDependencyKey
export const InjectableKey: unique symbol = Symbol('InjectableKey')
export const InjectableKey: unique symbol = Symbol.for('neemata:InjectableKey')
export type InjectableKey = typeof InjectableKey
export const LazyInjectableKey: unique symbol = Symbol('LazyInjectableKey')
export const LazyInjectableKey: unique symbol = Symbol.for(
'neemata:LazyInjectableKey',
)
export type LazyInjectableKey = typeof LazyInjectableKey
export const ValueInjectableKey: unique symbol = Symbol('ValueInjectableKey')
export const ValueInjectableKey: unique symbol = Symbol.for(
'neemata:ValueInjectableKey',
)
export type ValueInjectableKey = typeof ValueInjectableKey
export const FactoryInjectableKey: unique symbol = Symbol(
'FactoryInjectableKey',
export const FactoryInjectableKey: unique symbol = Symbol.for(
'neemata:FactoryInjectableKey',
)
export type FactoryInjectableKey = typeof FactoryInjectableKey
export const ProviderKey: unique symbol = Symbol('ProviderKey')
export const ProviderKey: unique symbol = Symbol.for('neemata:ProviderKey')
export type ProviderKey = typeof ProviderKey
export const ProcedureKey: unique symbol = Symbol('ProcedureKey')
export const ProcedureKey: unique symbol = Symbol.for('neemata:ProcedureKey')
export type ProcedureKey = typeof ProcedureKey
export const ProcedureSubscriptionKey: unique symbol = Symbol(
'ProcedureSubscriptionKey',
export const ProcedureSubscriptionKey: unique symbol = Symbol.for(
'neemata:ProcedureSubscriptionKey',
)
export type ProcedureSubscriptionKey = typeof ProcedureSubscriptionKey
export const ProcedureMetadataKey: unique symbol = Symbol(
'ProcedureMetadataKey',
export const ProcedureMetadataKey: unique symbol = Symbol.for(
'neemata:ProcedureMetadataKey',
)
export type ProcedureMetadataKey = typeof ProcedureMetadataKey
export const ServiceKey: unique symbol = Symbol('ServiceKey')
export const ServiceKey: unique symbol = Symbol.for('neemata:ServiceKey')
export type ServiceKey = typeof ServiceKey
export const TaskKey: unique symbol = Symbol('TaskKey')
export const TaskKey: unique symbol = Symbol.for('neemata:TaskKey')
export type TaskKey = typeof TaskKey
export const SubscriptionResponseKey: unique symbol = Symbol(
'SubscriptionResponseKey',
export const SubscriptionResponseKey: unique symbol = Symbol.for(
'neemata:SubscriptionResponseKey',
)
export type SubscriptionResponseKey = typeof SubscriptionResponseKey
import type { ApplicationOptions } from './application.ts'
import { builtin } from './common.ts'
import { Hook, TaskKey } from './constants.ts'
import { Hook, Scope, TaskKey } from './constants.ts'
import type {

@@ -86,3 +86,3 @@ Container,

const handler = params.handler
const parser = params.parser ?? notImplemented(name, 'parser')
const parser = params.parser
return { name, dependencies, handler, parser, [TaskKey]: true }

@@ -112,5 +112,3 @@ }

const { dependencies, handler } = task
const container = this.application.container.createScope(
this.application.container.scope,
)
const container = this.application.container.createScope(Scope.Global)
container.provide(builtin.taskSignal, ac.signal)

@@ -163,5 +161,1 @@ const context = await container.createContext(dependencies)

}
const notImplemented = (taskName: string, fnType: string) => () => {
throw new Error(`Task [${taskName}] ${fnType} is not implemented`)
}

@@ -17,10 +17,10 @@ {

"@types/node": "^18",
"@nmtjs/common": "0.3.10",
"@nmtjs/contract": "0.3.10",
"@nmtjs/type": "0.3.10"
"@nmtjs/common": "0.3.11",
"@nmtjs/type": "0.3.11",
"@nmtjs/contract": "0.3.11"
},
"peerDependencies": {
"@nmtjs/type": "0.3.10",
"@nmtjs/contract": "0.3.10",
"@nmtjs/common": "0.3.10"
"@nmtjs/common": "0.3.11",
"@nmtjs/type": "0.3.11",
"@nmtjs/contract": "0.3.11"
},

@@ -35,3 +35,3 @@ "files": [

],
"version": "0.3.10",
"version": "0.3.11",
"scripts": {

@@ -38,0 +38,0 @@ "build": "neemata-build ./index.ts './lib/**/*.ts'",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc