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

@magnetarjs/core

Package Overview
Dependencies
Maintainers
2
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magnetarjs/core - npm Package Compare versions

Comparing version 0.9.7 to 0.10.0

63

dist/index.js

@@ -120,2 +120,8 @@ "use strict";

}
function isDoOnFetchCount(payload) {
return (0, import_is_what.isFunction)(payload);
}
function isFetchCountResponse(payload) {
return (0, import_is_what.isPlainObject)(payload) && (0, import_is_what.isNumber)(payload.count);
}
function isDoOnFetch(payload) {

@@ -221,13 +227,2 @@ return (0, import_is_what.isFunction)(payload);

var import_is_what3 = require("is-what");
var MODULE_IDENTIFIER_SPLIT = " /// ";
function getPathFilterIdentifier(modulePath, moduleConfig) {
const { where, orderBy, startAfter, limit } = moduleConfig;
const config = JSON.stringify({ where, orderBy, startAfter, limit });
return `${modulePath}${MODULE_IDENTIFIER_SPLIT}${config}`;
}
function getPathWhereOrderByIdentifier(modulePath, moduleConfig) {
const { where, orderBy } = moduleConfig;
const config = JSON.stringify({ where, orderBy });
return `${modulePath}${MODULE_IDENTIFIER_SPLIT}${config}`;
}
function getPluginModuleConfig(moduleConfig, storeName) {

@@ -257,2 +252,12 @@ const { where, orderBy, limit, startAfter, configPerStore = {} } = moduleConfig;

}
function getCountFromDataStore(moduleConfig, globalConfig, collectionPath) {
const localStoreName = globalConfig.localStoreName;
throwIfNolocalStoreName(localStoreName);
const getModuleCount = globalConfig.stores[localStoreName].getModuleCount;
if (!getModuleCount) {
throw new Error("The data store did not provide a getModuleCount function!");
}
const pluginModuleConfig = getPluginModuleConfig(moduleConfig, localStoreName);
return getModuleCount({ collectionPath, pluginModuleConfig });
}
function proxify(target, propExecutionDic) {

@@ -353,8 +358,12 @@ const dataHandler = {

throwIfNoFnsToExecute(storesToExecute);
for (const modifyFn of modifyPayloadFnsMap[actionName]) {
payload = modifyFn(payload, docId);
if (actionName !== "fetchCount") {
for (const modifyFn of modifyPayloadFnsMap[actionName]) {
payload = modifyFn(payload, docId);
}
}
let stopExecution = false;
const doOnFetchFns = modifyReadResponseMap.added;
const doOnFetchCountFns = [];
const collectionFetchResult = /* @__PURE__ */ new Map();
let fetchCount = NaN;
let resultFromPlugin;

@@ -433,3 +442,20 @@ for (const [i, storeName] of storesToExecute.entries()) {

}
if (actionName === "fetchCount") {
if (isDoOnFetchCount(resultFromPlugin)) {
doOnFetchCountFns.push(resultFromPlugin);
}
if (isFetchCountResponse(resultFromPlugin)) {
for (const doOnFetchCountFn of doOnFetchCountFns) {
doOnFetchCountFn(resultFromPlugin);
}
if (isNaN(fetchCount) || resultFromPlugin.count > fetchCount) {
fetchCount = resultFromPlugin.count;
}
}
}
}
if (actionName === "fetchCount") {
resolve(fetchCount);
return;
}
if (actionName !== "fetch" && !writeLock.countdown) {

@@ -663,4 +689,5 @@ writeLock.countdown = setTimeout(writeLock.resolve, 5e3);

const fetch = handleActionPerStore(sharedParams, "fetch", import_types.actionNameTypeMap.fetch);
const fetchCount = handleActionPerStore(sharedParams, "fetchCount", import_types.actionNameTypeMap.fetchCount);
const stream = handleStreamPerStore([collectionPath, void 0], moduleConfig, globalConfig, import_types.actionNameTypeMap.stream, streaming, cacheStream, writeLockMap);
const actions = { stream, fetch, insert, delete: _delete };
const actions = { stream, fetch, fetchCount, insert, delete: _delete };
executeSetupModulePerStore(globalConfig.stores, [collectionPath, void 0], moduleConfig);

@@ -701,2 +728,3 @@ function where(fieldPath, operator, value) {

return proxify(moduleInstance, {
count: () => getCountFromDataStore(moduleConfig, globalConfig, collectionPath),
data: () => getDataFromDataStore(moduleConfig, globalConfig, collectionPath),

@@ -768,2 +796,3 @@ fetched: fetchMeta.get

// src/Magnetar.ts
var import_types3 = require("@magnetarjs/types");
function Magnetar(magnetarConfig) {

@@ -795,3 +824,3 @@ const globalConfig = defaultsGlobalConfig(magnetarConfig);

collectionNames.add(collectionPath);
const pathFilterIdentifier = getPathFilterIdentifier(modulePath, moduleConfig);
const pathFilterIdentifier = (0, import_types3.getPathFilterIdentifier)(modulePath, moduleConfig);
const fetchPromises = (0, import_getorset_anything2.mapGetOrSet)(

@@ -802,3 +831,3 @@ fetchPromiseMap,

);
const pathWhereOrderByIdentifier = getPathWhereOrderByIdentifier(modulePath, moduleConfig);
const pathWhereOrderByIdentifier = (0, import_types3.getPathWhereOrderByIdentifier)(modulePath, moduleConfig);
const fetchMeta = {

@@ -827,3 +856,3 @@ get: () => fetchMetaMap.get(pathWhereOrderByIdentifier) || { reachedEnd: false, cursor: void 0 },

for (const [identifier, closeStreamFn] of closeStreamFnMap) {
const openStreamPath = identifier.split(MODULE_IDENTIFIER_SPLIT)[0];
const openStreamPath = identifier.split(import_types3.MODULE_IDENTIFIER_SPLIT)[0];
if (openStreamPath === modulePath || openStreamPath.startsWith(modulePath + "/")) {

@@ -830,0 +859,0 @@ closeStreamFn();

{
"name": "@magnetarjs/core",
"version": "0.9.7",
"version": "0.10.0",
"sideEffects": false,

@@ -23,4 +23,4 @@ "description": "Magnetar core library.",

"dependencies": {
"@magnetarjs/types": "0.9.7",
"@magnetarjs/utils": "0.9.7",
"@magnetarjs/types": "0.10.0",
"@magnetarjs/utils": "0.10.0",
"getorset-anything": "^0.0.3",

@@ -31,3 +31,3 @@ "is-what": "^4.1.7",

"devDependencies": {
"@magnetarjs/test-utils": "0.9.7"
"@magnetarjs/test-utils": "0.10.0"
},

@@ -34,0 +34,0 @@ "keywords": [

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