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

@artus/core

Package Overview
Dependencies
Maintainers
7
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@artus/core - npm Package Compare versions

Comparing version 1.0.0-beta.0 to 1.0.0-beta.1

lib/injection.d.ts

2

lib/application.d.ts

@@ -9,2 +9,3 @@ import 'reflect-metadata';

import ConfigurationHandler from './configuration';
import { Logger } from './logger';
export declare class ArtusApplication implements Application {

@@ -19,2 +20,3 @@ manifest?: Manifest;

get frameworks(): Record<string, any>;
get logger(): Logger;
get packages(): Record<string, any>;

@@ -21,0 +23,0 @@ get trigger(): Trigger;

@@ -14,2 +14,3 @@ "use strict";

const configuration_1 = __importDefault(require("./configuration"));
const logger_1 = require("./logger");
class ArtusApplication {

@@ -31,2 +32,5 @@ constructor(opts) {

}
get logger() {
return this.container.get("artus#logger" /* Logger */);
}
get packages() {

@@ -54,2 +58,3 @@ return this.container.get("artus#packages" /* Packages */);

this.container.set({ type: configuration_1.default });
this.container.set({ type: logger_1.ArtusLogger });
this.container.set({ type: trigger_1.default });

@@ -56,0 +61,0 @@ this.container.set({ type: exception_1.ExceptionHandler });

2

lib/configuration/index.js

@@ -19,3 +19,3 @@ "use strict";

const merge_1 = require("../loader/utils/merge");
const compatible_require_1 = __importDefault(require("../utils/compatible-require"));
const compatible_require_1 = __importDefault(require("../utils/compatible_require"));
const decorator_1 = require("./decorator");

@@ -22,0 +22,0 @@ let ConfigurationHandler = ConfigurationHandler_1 = class ConfigurationHandler {

export declare const DEFAULT_LOADER = "module";
export declare const LOADER_NAME_META = "loader:name";
export declare const ArtusInjectPrefix = "artus#";
export declare const enum ArtusInjectEnum {
Application = "artus#application",
Trigger = "artus#trigger",
LifecycleManager = "artus#lifecycle-manager",
Config = "artus#config",
DefaultContainerName = "artus#default_container",
Frameworks = "artus#framework-config",
LifecycleManager = "artus#lifecycle-manager",
Logger = "artus#logger",
Packages = "artus#packages",
DefaultContainerName = "artus#default_container"
Trigger = "artus#trigger"
}

@@ -32,4 +34,4 @@ export declare const ARTUS_EXCEPTION_DEFAULT_LOCALE = "en";

export declare const PACKAGE_JSON = "package.json";
export declare const EXCEPTION_FILE = "artus-exception.yaml";
export declare const EXCEPTION_FILE = "exception.yaml";
export declare const DEFAULT_LOADER_LIST_WITH_ORDER: string[];
export declare const DEFAULT_CONFIG_DIR = "src/config";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_CONFIG_DIR = exports.DEFAULT_LOADER_LIST_WITH_ORDER = exports.EXCEPTION_FILE = exports.PACKAGE_JSON = exports.PLUGIN_META = exports.CONFIG_PATTERN = exports.PLUGIN_CONFIG_PATTERN = exports.FRAMEWORK_PATTERN = exports.DEFAULT_EXCLUDES = exports.HOOK_CONFIG_HANDLE = exports.HOOK_FILE_LOADER = exports.CONSTRUCTOR_PARAMS_CONTEXT = exports.CONSTRUCTOR_PARAMS_CONTAINER = exports.CONSTRUCTOR_PARAMS_APP = exports.CONSTRUCTOR_PARAMS = exports.HOOK_NAME_META_PREFIX = exports.ARTUS_DEFAULT_CONFIG_ENV = exports.ARTUS_SERVER_ENV = exports.ARTUS_EXCEPTION_DEFAULT_LOCALE = exports.ArtusInjectPrefix = exports.DEFAULT_LOADER = void 0;
exports.DEFAULT_CONFIG_DIR = exports.DEFAULT_LOADER_LIST_WITH_ORDER = exports.EXCEPTION_FILE = exports.PACKAGE_JSON = exports.PLUGIN_META = exports.CONFIG_PATTERN = exports.PLUGIN_CONFIG_PATTERN = exports.FRAMEWORK_PATTERN = exports.DEFAULT_EXCLUDES = exports.HOOK_CONFIG_HANDLE = exports.HOOK_FILE_LOADER = exports.CONSTRUCTOR_PARAMS_CONTEXT = exports.CONSTRUCTOR_PARAMS_CONTAINER = exports.CONSTRUCTOR_PARAMS_APP = exports.CONSTRUCTOR_PARAMS = exports.HOOK_NAME_META_PREFIX = exports.ARTUS_DEFAULT_CONFIG_ENV = exports.ARTUS_SERVER_ENV = exports.ARTUS_EXCEPTION_DEFAULT_LOCALE = exports.ArtusInjectPrefix = exports.LOADER_NAME_META = exports.DEFAULT_LOADER = void 0;
exports.DEFAULT_LOADER = 'module';
exports.LOADER_NAME_META = 'loader:name';
exports.ArtusInjectPrefix = 'artus#';

@@ -37,3 +38,3 @@ exports.ARTUS_EXCEPTION_DEFAULT_LOCALE = 'en';

exports.PACKAGE_JSON = 'package.json';
exports.EXCEPTION_FILE = 'artus-exception.yaml';
exports.EXCEPTION_FILE = 'exception.yaml';
exports.DEFAULT_LOADER_LIST_WITH_ORDER = [

@@ -40,0 +41,0 @@ 'exception',

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefineLoader = void 0;
const factory_1 = require("./factory");
const constraints_1 = require("../constraints");
const DefineLoader = (loaderName) => (target) => {
factory_1.LoaderFactory.registerLoader(loaderName, target);
Reflect.defineMetadata(constraints_1.LOADER_NAME_META, loaderName, target);
};
exports.DefineLoader = DefineLoader;
import { Container } from '@artus/injection';
import { Manifest, ManifestItem, LoaderConstructor, LoaderHookUnit, LoaderCheckOptions } from './types';
import ConfigurationHandler from '../configuration';
import { LifecycleManager } from '../lifecycle';
export declare class LoaderFactory {
private container;
private static loaderClazzMap;
static registerLoader(loaderName: string, clazz: LoaderConstructor): void;
static register(clazz: LoaderConstructor): void;
constructor(container: Container);
static create(container: Container): LoaderFactory;
get lifecycleManager(): LifecycleManager;
get configurationHandler(): ConfigurationHandler;
loadManifest(manifest: Manifest): Promise<void>;

@@ -10,0 +14,0 @@ loadItemList(itemList?: ManifestItem[], hookMap?: Record<string, LoaderHookUnit>): Promise<void>;

@@ -33,3 +33,3 @@ "use strict";

const configuration_1 = __importDefault(require("../configuration"));
const compatible_require_1 = __importDefault(require("../utils/compatible-require"));
const compatible_require_1 = __importDefault(require("../utils/compatible_require"));
class LoaderFactory {

@@ -39,3 +39,4 @@ constructor(container) {

}
static registerLoader(loaderName, clazz) {
static register(clazz) {
const loaderName = Reflect.getMetadata(constraints_1.LOADER_NAME_META, clazz);
this.loaderClazzMap.set(loaderName, clazz);

@@ -46,14 +47,18 @@ }

}
get lifecycleManager() {
return this.container.get("artus#lifecycle-manager" /* LifecycleManager */);
}
get configurationHandler() {
return this.container.get(configuration_1.default);
}
async loadManifest(manifest) {
const lifecycleManager = this.container.get("artus#lifecycle-manager" /* LifecycleManager */);
const configurationHandler = this.container.get(configuration_1.default);
await this.loadItemList(manifest.items, {
config: {
before: () => lifecycleManager.emitHook('configWillLoad'),
before: () => this.lifecycleManager.emitHook('configWillLoad'),
after: () => {
this.container.set({
id: "artus#config" /* Config */,
value: configurationHandler.getMergedConfig()
value: this.configurationHandler.getMergedConfig()
});
lifecycleManager.emitHook('configDidLoad');
this.lifecycleManager.emitHook('configDidLoad');
}

@@ -64,3 +69,3 @@ },

id: "artus#framework-config" /* Frameworks */,
value: configurationHandler.getFrameworkConfig()
value: this.configurationHandler.getFrameworkConfig()
})

@@ -71,3 +76,3 @@ },

id: "artus#packages" /* Packages */,
value: configurationHandler.getPackages()
value: this.configurationHandler.getPackages()
})

@@ -74,0 +79,0 @@ }

@@ -42,3 +42,3 @@ "use strict";

const decorator_1 = require("../decorator");
const compatible_require_1 = __importDefault(require("../../utils/compatible-require"));
const compatible_require_1 = __importDefault(require("../../utils/compatible_require"));
const utils_1 = require("../../utils");

@@ -45,0 +45,0 @@ let ConfigLoader = class ConfigLoader {

@@ -14,3 +14,3 @@ "use strict";

const exception_1 = require("../../exception");
const load_meta_file_1 = require("../../utils/load-meta-file");
const load_meta_file_1 = require("../../utils/load_meta_file");
const constraints_1 = require("../../constraints");

@@ -17,0 +17,0 @@ const utils_1 = require("../../utils");

@@ -1,8 +0,9 @@

export * from './module';
export * from './config';
export * from './exception';
export * from './lifecycle';
export * from './pluginMeta';
export * from './pluginConfig';
export * from './frameworkConfig';
export * from './package';
import ModuleLoader from './module';
import ConfigLoader from './config';
import ExceptionLoader from './exception';
import LifecycleLoader from './lifecycle';
import PluginMetaLoader from './plugin_meta';
import PluginConfigLoader from './plugin_config';
import FrameworkConfigLoader from './framework_config';
import PackageLoader from './package';
export { ModuleLoader, ConfigLoader, ExceptionLoader, LifecycleLoader, PluginMetaLoader, PluginConfigLoader, FrameworkConfigLoader, PackageLoader, };
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./module"), exports);
__exportStar(require("./config"), exports);
__exportStar(require("./exception"), exports);
__exportStar(require("./lifecycle"), exports);
__exportStar(require("./pluginMeta"), exports);
__exportStar(require("./pluginConfig"), exports);
__exportStar(require("./frameworkConfig"), exports);
__exportStar(require("./package"), exports);
exports.PackageLoader = exports.FrameworkConfigLoader = exports.PluginConfigLoader = exports.PluginMetaLoader = exports.LifecycleLoader = exports.ExceptionLoader = exports.ConfigLoader = exports.ModuleLoader = void 0;
const module_1 = __importDefault(require("./module"));
exports.ModuleLoader = module_1.default;
const config_1 = __importDefault(require("./config"));
exports.ConfigLoader = config_1.default;
const exception_1 = __importDefault(require("./exception"));
exports.ExceptionLoader = exception_1.default;
const lifecycle_1 = __importDefault(require("./lifecycle"));
exports.LifecycleLoader = lifecycle_1.default;
const plugin_meta_1 = __importDefault(require("./plugin_meta"));
exports.PluginMetaLoader = plugin_meta_1.default;
const plugin_config_1 = __importDefault(require("./plugin_config"));
exports.PluginConfigLoader = plugin_config_1.default;
const framework_config_1 = __importDefault(require("./framework_config"));
exports.FrameworkConfigLoader = framework_config_1.default;
const package_1 = __importDefault(require("./package"));
exports.PackageLoader = package_1.default;

@@ -16,3 +16,3 @@ "use strict";

const decorator_1 = require("../decorator");
const compatible_require_1 = __importDefault(require("../../utils/compatible-require"));
const compatible_require_1 = __importDefault(require("../../utils/compatible_require"));
let LifecycleLoader = class LifecycleLoader {

@@ -19,0 +19,0 @@ constructor(container) {

@@ -16,3 +16,3 @@ "use strict";

const decorator_1 = require("../decorator");
const compatible_require_1 = __importDefault(require("../../utils/compatible-require"));
const compatible_require_1 = __importDefault(require("../../utils/compatible_require"));
let ModuleLoader = class ModuleLoader {

@@ -19,0 +19,0 @@ constructor(container) {

@@ -17,3 +17,3 @@ "use strict";

const decorator_1 = require("../decorator");
const compatible_require_1 = __importDefault(require("../../utils/compatible-require"));
const compatible_require_1 = __importDefault(require("../../utils/compatible_require"));
const constraints_1 = require("../../constraints");

@@ -20,0 +20,0 @@ const utils_1 = require("../../utils");

import { LoaderFactory } from './factory';
import { Manifest, ManifestItem, Loader, LoaderConstructor } from './types';
import { DefineLoader } from './decorator';
import './impl';
export { DefineLoader, LoaderFactory, Loader, LoaderConstructor, Manifest, ManifestItem, };
import BaseLoader from './base';
export { DefineLoader, LoaderFactory, BaseLoader, Loader, LoaderConstructor, Manifest, ManifestItem, };
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoaderFactory = exports.DefineLoader = void 0;
exports.BaseLoader = exports.LoaderFactory = exports.DefineLoader = void 0;
const factory_1 = require("./factory");

@@ -8,3 +34,9 @@ Object.defineProperty(exports, "LoaderFactory", { enumerable: true, get: function () { return factory_1.LoaderFactory; } });

Object.defineProperty(exports, "DefineLoader", { enumerable: true, get: function () { return decorator_1.DefineLoader; } });
const base_1 = __importDefault(require("./base"));
exports.BaseLoader = base_1.default;
// Import inner impls
require("./impl");
const LoaderImpls = __importStar(require("./impl"));
// Register inner impls
for (const [_, impl] of Object.entries(LoaderImpls)) {
factory_1.LoaderFactory.register(impl);
}

@@ -9,3 +9,3 @@ "use strict";

const base_1 = require("./base");
const load_meta_file_1 = require("../utils/load-meta-file");
const load_meta_file_1 = require("../utils/load_meta_file");
const fs_1 = require("../utils/fs");

@@ -12,0 +12,0 @@ class ArtusPlugin extends base_1.BasePlugin {

@@ -9,2 +9,3 @@ export declare const enum PluginType {

type?: PluginType;
configDir?: string;
}

@@ -11,0 +12,0 @@ export interface PluginDependencyItem {

@@ -48,3 +48,13 @@ "use strict";

this.itemMap = new Map(this.options.loaderListGenerator(constraints_1.DEFAULT_LOADER_LIST_WITH_ORDER)
.map((loaderName) => ([loaderName, []])));
.map((loaderNameOrClazz) => {
if (typeof loaderNameOrClazz === 'string') {
return [loaderNameOrClazz, []];
}
const loaderClazz = loaderNameOrClazz;
const loaderName = Reflect.getMetadata(constraints_1.LOADER_NAME_META, loaderClazz);
if (!loaderName) {
throw new Error(`Loader ${loaderClazz.name} must have a @DefineLoader() decorator.`);
}
return [loaderName, []];
}));
this.loaderFactory = loader_1.LoaderFactory.create(new injection_1.Container("artus#default_container" /* DefaultContainerName */));

@@ -85,5 +95,5 @@ }

async scanItems(root, env) {
var _a, _b;
var _a, _b, _c;
// 0. Scan Application
await this.walk(root, { source: 'app', baseDir: root });
await this.walk(root, { source: 'app', baseDir: root, configDir: this.options.configDir });
// 1. Scan Frameworks

@@ -111,3 +121,8 @@ await this.recurseFramework(env, root, []);

});
await this.walk(plugin.importPath, { source: 'plugin', baseDir: plugin.importPath, unitName: plugin.name });
await this.walk(plugin.importPath, {
source: 'plugin',
baseDir: plugin.importPath,
unitName: plugin.name,
configDir: (_c = plugin.metadata.configDir) !== null && _c !== void 0 ? _c : this.options.configDir
});
}

@@ -129,12 +144,10 @@ const result = {

baseDir: baseFrameworkPath,
unitName: baseFrameworkPath
unitName: baseFrameworkPath,
configDir: this.options.configDir
});
await this.recurseFramework(env, baseFrameworkPath, executed.concat(done));
}
async walk(root, { source, unitName, baseDir } = {
source: '',
unitName: this.options.appName,
baseDir: ''
}) {
async walk(root, options) {
var _a;
const { source, unitName, baseDir, configDir } = options;
if (!(0, fs_1.existsSync)(root)) {

@@ -163,3 +176,3 @@ // TODO: use artus logger instead

}
await this.walk(realPath, { source, unitName, baseDir });
await this.walk(realPath, { source, unitName, baseDir, configDir });
continue;

@@ -178,3 +191,3 @@ }

baseDir,
configDir: this.options.configDir,
configDir
}),

@@ -181,0 +194,0 @@ source

@@ -0,1 +1,2 @@

import { BaseLoader } from "../loader";
export interface ScannerOptions {

@@ -8,3 +9,3 @@ appName: string;

envs?: string[];
loaderListGenerator: (defaultLoaderList: string[]) => string[];
loaderListGenerator: (defaultLoaderList: string[]) => (string | typeof BaseLoader)[];
}

@@ -14,2 +15,3 @@ export interface WalkOptions {

baseDir: string;
configDir: string;
unitName?: string;

@@ -16,0 +18,0 @@ }

@@ -24,6 +24,5 @@ "use strict";

async initContext(input) {
return new pipeline_1.Context(input, new pipeline_1.Output(), {
// SEEME: need replace to injection provided container getter way in future.
parentContainer: this.app.getContainer()
});
const ctx = new pipeline_1.Context(input, new pipeline_1.Output());
ctx.container = new injection_1.ExecutionContainer(ctx, this.app.getContainer());
return ctx;
}

@@ -30,0 +29,0 @@ async startPipeline(input = new pipeline_1.Input()) {

{
"name": "@artus/core",
"version": "1.0.0-beta.0",
"version": "1.0.0-beta.1",
"description": "Core package of Artus",
"main": "lib/index.js",
"exports": {
".": "./lib/index.js",
"./injection": "./lib/injection.js",
"./pipeline": "./lib/pipeline.js"
},
"files": [
"lib"
],
"scripts": {
"build": "tsc",
"build": "tsc -p ./tsconfig.build.json",
"test": "jest --detectOpenHandles",

@@ -36,4 +44,4 @@ "ci": "npm run test"

"dependencies": {
"@artus/injection": "^0.1.1",
"@artus/pipeline": "^0.1.6",
"@artus/injection": "^0.2.0",
"@artus/pipeline": "^0.2.1",
"deepmerge": "^4.2.2",

@@ -40,0 +48,0 @@ "js-yaml": "^4.1.0",

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