Socket
Socket
Sign inDemoInstall

@moralisweb3/common-core

Package Overview
Dependencies
Maintainers
8
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moralisweb3/common-core - npm Package Compare versions

Comparing version 2.10.4 to 2.11.0

6

lib/Core.d.ts

@@ -23,3 +23,3 @@ import { Module, ModuleFactory } from './Modules/Module';

get isStarted(): boolean;
static readonly libVersion = "2.10.4";
static readonly libVersion = "2.11.0";
constructor(modules: Modules, config: Config, logger: LoggerController);

@@ -35,3 +35,3 @@ /**

registerModule: (module: Module | ModuleFactory) => void;
getModule: <CurrentModule extends Module = Module>(name: string) => CurrentModule;
getModule: <CurrentModule extends Module<any> = Module<any>>(name: string) => CurrentModule;
/**

@@ -43,4 +43,4 @@ * Start all modules, this function should be called before any interaction with a module,

*/
start: (providedConfig?: Partial<MoralisCoreConfigValues>) => void;
start: (providedConfig?: Partial<MoralisCoreConfigValues>) => Promise<void>;
}
//# sourceMappingURL=Core.d.ts.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -52,20 +88,31 @@ exports.Core = void 0;

*/
this.start = function (providedConfig) {
if (_this._isStarted) {
throw new Error_1.MoralisError({
message: 'Modules are started already. This method should be called only one time.',
code: Error_1.CoreErrorCode.ALREADY_INITIALIZED,
});
}
_this._isStarted = true;
if (providedConfig) {
_this.config.merge(providedConfig);
}
_this.logger.verbose('Starting all registered modules', {
moduleNames: _this.modules.listNames(),
this.start = function (providedConfig) { return __awaiter(_this, void 0, void 0, function () {
var allModules;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this._isStarted) {
throw new Error_1.MoralisError({
message: 'Modules are started already. This method should be called only one time.',
code: Error_1.CoreErrorCode.ALREADY_INITIALIZED,
});
}
this._isStarted = true;
allModules = this.modules.list();
if (providedConfig) {
this.config.merge(providedConfig);
}
this.logger.verbose('Starting all registered modules', {
moduleNames: this.modules.listNames(),
});
return [4 /*yield*/, Promise.all(allModules.map(function (module) { return module.start(); }))];
case 1:
_a.sent();
this.logger.verbose('Finished starting all registered modules', {
moduleNames: this.modules.listNames(),
});
return [2 /*return*/];
}
});
_this.logger.verbose('Finished starting all registered modules', {
moduleNames: _this.modules.listNames(),
});
};
}); };
}

@@ -72,0 +119,0 @@ Core.create = function () {

@@ -1,3 +0,4 @@

import { ModuleType } from './ModuleType';
import { Module } from './Module';
import { EventMap } from 'typed-emitter';
import { Core } from '../Core';
/**

@@ -10,6 +11,6 @@ * The base class of every Moralis Api class that gets registered as a module via MoralisModules

*/
export interface ApiModule extends Module {
type: ModuleType.API;
baseUrl: string;
export declare abstract class ApiModule<Events extends EventMap = any> extends Module<Events> {
readonly baseUrl: string;
constructor(name: string, core: Core, baseUrl: string);
}
//# sourceMappingURL=ApiModule.d.ts.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiModule = void 0;
var ModuleType_1 = require("./ModuleType");
var Module_1 = require("./Module");
/**
* The base class of every Moralis Api class that gets registered as a module via MoralisModules
* It should always be created with:
* - `name`: name of the module (should be unique)
* - `core`: the Core instance
* - `baseUrl`: the base url where of the api
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var ApiModule = /** @class */ (function (_super) {
__extends(ApiModule, _super);
function ApiModule(name, core, baseUrl) {
var _this = _super.call(this, name, core, ModuleType_1.ModuleType.API) || this;
_this.baseUrl = baseUrl;
return _this;
}
return ApiModule;
}(Module_1.Module));
exports.ApiModule = ApiModule;
//# sourceMappingURL=ApiModule.js.map
import { Core } from '../Core';
import { LoggerController } from '../controllers/LoggerController';
import { ModuleType } from './ModuleType';
import TypedEmitter, { EventMap } from 'typed-emitter';
/**
* The base interface of every Moralis module that gets registered as a module via MoralisModules
* The base class of every Moralis class that gets registered as a module via MoralisModules
* It should always be created with:

@@ -12,9 +14,24 @@ * - `name`: name of the module (should be unique)

*/
export interface Module {
name: string;
type?: ModuleType;
export declare abstract class Module<Events extends EventMap = any> {
readonly name: string;
protected readonly core: Core;
readonly type: ModuleType;
protected readonly logger: LoggerController;
protected readonly emitter: TypedEmitter<Events>;
constructor(name: string, core: Core, type?: ModuleType);
abstract setup(): void;
/**
* Initializes the module.
* Start the module (if needed).
* This function can be used to initialize variables etc.
*/
setup?: () => void;
abstract start(): void | Promise<void>;
/**
* Any cleanup that needs to be done for removing this module.
* It also should remove the module via `this.core.modules.remove(this.name)`
*/
cleanUp(): void;
/**
* Listen to an event, and returns a cleanup function
*/
listen<Event extends keyof Events>(eventName: Event, listener: Events[Event]): () => TypedEmitter<Events>;
}

@@ -21,0 +38,0 @@ export interface ModuleFactory {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Module = void 0;
var eventemitter3_1 = __importDefault(require("eventemitter3"));
var LoggerController_1 = require("../controllers/LoggerController");
var ModuleType_1 = require("./ModuleType");
/**
* The base class of every Moralis class that gets registered as a module via MoralisModules
* It should always be created with:
* - `name`: name of the module (should be unique)
* - `core`: the Core instance
* - `type`: (optional) CoreModuleType, defaults to CoreModuleType.DEFAULT
*
* When creating an api, or network module, you should use the ApiModule or NetworkModule
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var Module = /** @class */ (function () {
function Module(name, core, type) {
if (type === void 0) { type = ModuleType_1.ModuleType.DEFAULT; }
this.name = name;
this.core = core;
this.type = type;
this.logger = LoggerController_1.LoggerController.create(this.name, this.core);
this.emitter = new eventemitter3_1.default();
}
/**
* Any cleanup that needs to be done for removing this module.
* It also should remove the module via `this.core.modules.remove(this.name)`
*/
Module.prototype.cleanUp = function () {
this.core.modules.remove(this.name);
};
/**
* Listen to an event, and returns a cleanup function
*/
Module.prototype.listen = function (eventName, listener) {
var _this = this;
this.emitter.on(eventName, listener);
return function () { return _this.emitter.removeListener(eventName, listener); };
};
return Module;
}());
exports.Module = Module;
//# sourceMappingURL=Module.js.map

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

this.modules.set(module.name, module);
if (module.setup) {
module.setup();
}
module.setup();
};

@@ -38,0 +36,0 @@ /**

@@ -14,3 +14,3 @@ import { ApiModule } from './ApiModule';

*/
export declare const isApiModule: (moralisClass: Module) => moralisClass is ApiModule;
export declare const isApiModule: (moralisClass: Module) => moralisClass is ApiModule<any>;
//# sourceMappingURL=utils.d.ts.map

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

export declare const LIB_VERSION = "2.10.4";
export declare const LIB_VERSION = "2.11.0";
//# sourceMappingURL=version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LIB_VERSION = void 0;
exports.LIB_VERSION = "2.10.4";
exports.LIB_VERSION = "2.11.0";
//# sourceMappingURL=version.js.map
{
"name": "@moralisweb3/common-core",
"author": "Moralis",
"version": "2.10.4",
"version": "2.11.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "main": "./lib/index.js",

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

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