New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@medusajs/modules-sdk

Package Overview
Dependencies
Maintainers
2
Versions
3114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@medusajs/modules-sdk - npm Package Compare versions

Comparing version 1.8.8-snapshot-20230606085136 to 1.8.8-snapshot-20230606091839

3

dist/definitions.d.ts

@@ -6,3 +6,4 @@ import { ModuleDefinition } from "@medusajs/types";

INVENTORY = "inventoryService",
CACHE = "cacheService"
CACHE = "cacheService",
PRODUCT = "productService"
}

@@ -9,0 +10,0 @@ export declare const ModulesDefinition: {

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

Modules["CACHE"] = "cacheService";
Modules["PRODUCT"] = "productService";
})(Modules = exports.Modules || (exports.Modules = {}));

@@ -65,2 +66,14 @@ exports.ModulesDefinition = {

},
[Modules.PRODUCT]: {
key: Modules.PRODUCT,
registrationName: "productService",
defaultPackage: false,
label: "productService",
isRequired: false,
canOverride: true,
dependencies: [],
defaultModuleDeclaration: {
scope: types_1.MODULE_SCOPE.EXTERNAL,
},
},
};

@@ -67,0 +80,0 @@ exports.MODULE_DEFINITIONS = Object.values(exports.ModulesDefinition);

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

}
if (!resolution.resolutionPath) {
if (resolution.resolutionPath === false) {
container.register({

@@ -33,0 +33,0 @@ [registrationName]: (0, awilix_1.asValue)(undefined),

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

import { ExternalModuleDeclaration, InternalModuleDeclaration, ModuleResolution } from "@medusajs/types";
import { ExternalModuleDeclaration, InternalModuleDeclaration, ModuleExports, ModuleResolution } from "@medusajs/types";
export declare const registerModules: (modules?: Record<string, false | string | Partial<InternalModuleDeclaration | ExternalModuleDeclaration>>) => Record<string, ModuleResolution>;
export declare const registerMedusaModule: (moduleKey: string, moduleDeclaration: InternalModuleDeclaration | ExternalModuleDeclaration) => Record<string, ModuleResolution>;
export declare const registerMedusaModule: (moduleKey: string, moduleDeclaration: InternalModuleDeclaration | ExternalModuleDeclaration, moduleExports?: ModuleExports) => Record<string, ModuleResolution>;

@@ -8,4 +8,4 @@ "use strict";

const types_1 = require("@medusajs/types");
const definitions_1 = __importDefault(require("../definitions"));
const resolve_cwd_1 = __importDefault(require("resolve-cwd"));
const definitions_1 = __importDefault(require("../definitions"));
const registerModules = (modules) => {

@@ -26,3 +26,3 @@ const moduleResolutions = {};

exports.registerModules = registerModules;
const registerMedusaModule = (moduleKey, moduleDeclaration) => {
const registerMedusaModule = (moduleKey, moduleDeclaration, moduleExports) => {
const moduleResolutions = {};

@@ -37,3 +37,3 @@ for (const definition of definitions_1.default) {

}
moduleResolutions[definition.key] = getInternalModuleResolution(definition, moduleDeclaration);
moduleResolutions[definition.key] = getInternalModuleResolution(definition, moduleDeclaration, moduleExports);
}

@@ -43,3 +43,3 @@ return moduleResolutions;

exports.registerMedusaModule = registerMedusaModule;
function getInternalModuleResolution(definition, moduleConfig) {
function getInternalModuleResolution(definition, moduleConfig, moduleExports) {
if (typeof moduleConfig === "boolean") {

@@ -63,3 +63,7 @@ if (!moduleConfig && definition.isRequired) {

if (definition.canOverride && (isString || (isObj && moduleConfig.resolve))) {
resolutionPath = (0, resolve_cwd_1.default)(isString ? moduleConfig : moduleConfig.resolve);
resolutionPath = !moduleExports
? (0, resolve_cwd_1.default)(isString ? moduleConfig : moduleConfig.resolve)
: // Explicitly assign an empty string, later, we will check if the value is exactly false.
// This allows to continue the module loading while using the module exports instead of re importing the module itself during the process.
"";
}

@@ -78,2 +82,3 @@ const moduleDeclaration = isObj ? moduleConfig : {};

},
moduleExports,
options: isObj ? moduleConfig.options ?? {} : {},

@@ -80,0 +85,0 @@ };

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

const awilix_1 = require("awilix");
const medusa_telemetry_1 = require("medusa-telemetry");
// import { trackInstallation } from "medusa-telemetry"
async function loadInternalModule(container, resolution, logger) {

@@ -37,3 +37,5 @@ const registrationName = resolution.definition.registrationName;

try {
loadedModule = (await Promise.resolve().then(() => __importStar(require(resolution.resolutionPath)))).default;
loadedModule =
resolution.moduleExports ??
(await Promise.resolve().then(() => __importStar(require(resolution.resolutionPath)))).default;
}

@@ -103,6 +105,11 @@ catch (error) {

});
(0, medusa_telemetry_1.trackInstallation)({
/*
trackInstallation(
{
module: resolution.definition.key,
resolution: resolution.resolutionPath,
}, "module");
},
"module"
)
*/
}

@@ -109,0 +116,0 @@ exports.loadInternalModule = loadInternalModule;

@@ -1,5 +0,5 @@

import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/types";
import { ExternalModuleDeclaration, InternalModuleDeclaration, ModuleExports } from "@medusajs/types";
export declare class MedusaModule {
private static instances_;
static bootstrap(moduleKey: string, defaultPath: string, declaration?: InternalModuleDeclaration | ExternalModuleDeclaration, injectedDependencies?: Record<string, any>): Promise<{
static bootstrap(moduleKey: string, defaultPath: string, declaration?: InternalModuleDeclaration | ExternalModuleDeclaration, moduleExports?: ModuleExports, injectedDependencies?: Record<string, any>): Promise<{
[key: string]: any;

@@ -6,0 +6,0 @@ }>;

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

class MedusaModule {
static async bootstrap(moduleKey, defaultPath, declaration, injectedDependencies) {
if (MedusaModule.instances_.has(moduleKey)) {
return MedusaModule.instances_.get(moduleKey);
static async bootstrap(moduleKey, defaultPath, declaration, moduleExports, injectedDependencies) {
const hashKey = (0, utils_1.simpleHash)((0, utils_1.stringifyCircular)({ moduleKey, defaultPath, declaration }));
if (MedusaModule.instances_.has(hashKey)) {
return MedusaModule.instances_.get(hashKey);
}

@@ -36,4 +37,8 @@ let modDeclaration = declaration;

}
const moduleResolutions = (0, loaders_1.registerMedusaModule)(moduleKey, modDeclaration);
await (0, loaders_1.moduleLoader)({ container, moduleResolutions, logger });
const moduleResolutions = (0, loaders_1.registerMedusaModule)(moduleKey, modDeclaration, moduleExports);
await (0, loaders_1.moduleLoader)({
container,
moduleResolutions,
logger,
});
const services = {};

@@ -45,3 +50,3 @@ for (const resolution of Object.values(moduleResolutions)) {

}
MedusaModule.instances_.set(moduleKey, services);
MedusaModule.instances_.set(hashKey, services);
return services;

@@ -48,0 +53,0 @@ }

{
"name": "@medusajs/modules-sdk",
"version": "1.8.8-snapshot-20230606085136",
"version": "1.8.8-snapshot-20230606091839",
"description": "SDK for medusa modules",

@@ -26,7 +26,5 @@ "main": "dist/index.js",

"dependencies": {
"@medusajs/types": "1.8.8-snapshot-20230606085136",
"@medusajs/utils": "1.9.0",
"@medusajs/types": "1.8.8-snapshot-20230606091839",
"@medusajs/utils": "1.9.1-snapshot-20230606091839",
"awilix": "^8.0.0",
"glob": "7.1.6",
"medusa-telemetry": "^0.0.16",
"resolve-cwd": "^3.0.0"

@@ -37,4 +35,5 @@ },

"build": "tsc --build",
"test": "jest"
"test": "jest",
"watch": "tsc --build --watch"
}
}

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