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

@magnetarjs/plugin-vue3

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magnetarjs/plugin-vue3 - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

33

dist/index.cjs.js

@@ -101,8 +101,35 @@ 'use strict';

return function ({ payload, collectionPath, docId, pluginModuleConfig, }) {
const doOnFetchAction = (payload, meta) => {
if (payload && payload.ifUnfetched === true) {
if (!docId) {
const localDocs = [...data[collectionPath].entries()].map(([_docId, data]) => ({
data,
exists: 'unknown',
id: _docId,
}));
const fetchResponse = { docs: localDocs };
return fetchResponse;
}
if (docId) {
const localDoc = data[collectionPath].get(docId);
// if already fetched
if (localDoc) {
const fetchResponse = {
docs: [
{
data: localDoc,
exists: 'unknown',
id: docId,
},
],
};
return fetchResponse;
}
}
}
const doOnFetchAction = (_payload, meta) => {
// abort updating local state if the payload is undefined
if (payload === undefined)
if (_payload === undefined)
return;
insertActionFactory(data, Vue3StoreOptions)({
payload,
payload: _payload,
collectionPath,

@@ -109,0 +136,0 @@ docId,

@@ -97,8 +97,35 @@ import { copy } from 'copy-anything';

return function ({ payload, collectionPath, docId, pluginModuleConfig, }) {
const doOnFetchAction = (payload, meta) => {
if (payload && payload.ifUnfetched === true) {
if (!docId) {
const localDocs = [...data[collectionPath].entries()].map(([_docId, data]) => ({
data,
exists: 'unknown',
id: _docId,
}));
const fetchResponse = { docs: localDocs };
return fetchResponse;
}
if (docId) {
const localDoc = data[collectionPath].get(docId);
// if already fetched
if (localDoc) {
const fetchResponse = {
docs: [
{
data: localDoc,
exists: 'unknown',
id: docId,
},
],
};
return fetchResponse;
}
}
}
const doOnFetchAction = (_payload, meta) => {
// abort updating local state if the payload is undefined
if (payload === undefined)
if (_payload === undefined)
return;
insertActionFactory(data, Vue3StoreOptions)({
payload,
payload: _payload,
collectionPath,

@@ -105,0 +132,0 @@ docId,

8

package.json
{
"name": "@magnetarjs/plugin-vue3",
"version": "0.0.15",
"version": "0.0.16",
"sideEffects": false,

@@ -23,3 +23,3 @@ "description": "Magnetar plugin vue3",

"dependencies": {
"@magnetarjs/core": "^0.0.18",
"@magnetarjs/core": "^0.0.19",
"copy-anything": "^2.0.3",

@@ -34,3 +34,3 @@ "fast-sort": "^3.0.1",

"devDependencies": {
"@magnetarjs/test-utils": "^0.0.9",
"@magnetarjs/test-utils": "^0.0.10",
"ava": "^3.15.0",

@@ -82,3 +82,3 @@ "vue": "3.0.11"

},
"gitHead": "219612ce9ddaa585f3eb888249dcaacb0208e0e5"
"gitHead": "0894958dbdebbe4ec1adeb418d4d76050bd5c51d"
}

@@ -6,2 +6,3 @@ import {

PluginFetchActionPayload,
DocMetadata,
} from '@magnetarjs/core'

@@ -21,5 +22,38 @@ import { Vue3StoreModuleConfig, Vue3StoreOptions } from '../CreatePlugin'

}: PluginFetchActionPayload<Vue3StoreModuleConfig>): FetchResponse | DoOnFetch {
const doOnFetchAction: DoOnFetch = (payload, meta): void => {
if (payload && payload.ifUnfetched === true) {
if (!docId) {
const localDocs: DocMetadata[] = [...data[collectionPath].entries()].map(
([_docId, data]) => ({
data,
exists: 'unknown',
id: _docId,
})
)
const fetchResponse: FetchResponse = { docs: localDocs }
return fetchResponse
}
if (docId) {
const localDoc = data[collectionPath].get(docId)
// if already fetched
if (localDoc) {
const fetchResponse: FetchResponse = {
docs: [
{
data: localDoc,
exists: 'unknown',
id: docId,
},
],
}
return fetchResponse
}
// if not yet fetched
if (!localDoc) {
// fall through to returning DoOnFetch down below
}
}
}
const doOnFetchAction: DoOnFetch = (_payload, meta): void => {
// abort updating local state if the payload is undefined
if (payload === undefined) return
if (_payload === undefined) return

@@ -30,3 +64,3 @@ insertActionFactory(

)({
payload,
payload: _payload,
collectionPath,

@@ -33,0 +67,0 @@ docId,

@@ -34,2 +34,14 @@ import test from 'ava'

test('fetch (document) if unfetched', async (t) => {
/// get resolves once all stores have given a response with data
const { trainerModule } = createMagnetarInstance()
t.deepEqual(trainerModule.data, { name: 'Luca', age: 10 })
try {
await trainerModule.fetch({ ifUnfetched: true })
} catch (error) {
t.fail(error)
}
t.deepEqual(trainerModule.data, { name: 'Luca', age: 10 })
})
test('fetch (collection) where-filter: ==', async (t) => {

@@ -36,0 +48,0 @@ const { pokedexModule } = createMagnetarInstance()

@@ -46,3 +46,3 @@ import test from 'ava'

const { pokedexModule } = createMagnetarInstance()
// the original state has 1 pokemon already
// the original state has 1 Pokemon already
t.is(pokedexModule.data.size, 1)

@@ -67,6 +67,6 @@ // let's get some more

if (closeStream) closeStream()
// the queried instance only has these 3 pokemon
// the queried instance only has these 3 Pokemon
t.deepEqual([...pokedexModuleWithQuery.data.values()], [pokedex(6), pokedex(38), pokedex(78)])
// the main instance has one pokemon from the beginning
// the main instance has one Pokemon from the beginning
t.is(pokedexModule.data.size, 4)
})

@@ -56,3 +56,3 @@ import { Magnetar, MagnetarInstance, CollectionInstance, DocInstance } from '../../../core/src'

})
const trainerModule = magnetar.doc<TrainerModuleData>('data/trainer', {
const trainerModule = magnetar.doc<TrainerModuleData>('app-data/trainer', {
configPerStore: {

@@ -59,0 +59,0 @@ local: { initialData: getInitialDataDocument() }, // path for the plugin

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