@magnetarjs/plugin-vue3
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -7,2 +7,2 @@ import type { PluginDeleteAction } from '@magnetarjs/types'; | ||
}>; | ||
}, Vue3StoreOptions: Vue3StoreOptions, makeBackup?: MakeRestoreBackup): PluginDeleteAction; | ||
}, vue3StoreOptions: Vue3StoreOptions, makeBackup?: MakeRestoreBackup): PluginDeleteAction; |
import { isFullString } from 'is-what'; | ||
export function deleteActionFactory(data, Vue3StoreOptions, makeBackup) { | ||
export function deleteActionFactory(data, vue3StoreOptions, makeBackup) { | ||
return function ({ payload, collectionPath, docId, pluginModuleConfig, }) { | ||
@@ -4,0 +4,0 @@ const _docId = docId || payload; |
@@ -7,2 +7,2 @@ import type { PluginDeletePropAction } from '@magnetarjs/types'; | ||
}>; | ||
}, Vue3StoreOptions: Vue3StoreOptions, makeBackup?: MakeRestoreBackup): PluginDeletePropAction; | ||
}, vue3StoreOptions: Vue3StoreOptions, makeBackup?: MakeRestoreBackup): PluginDeletePropAction; |
import { objGetOrSet } from 'getorset-anything'; | ||
import { isArray } from 'is-what'; | ||
import { getProp } from 'path-to-prop'; | ||
export function deletePropActionFactory(data, Vue3StoreOptions, makeBackup) { | ||
export function deletePropActionFactory(data, vue3StoreOptions, makeBackup) { | ||
return function ({ payload, collectionPath, docId, pluginModuleConfig, }) { | ||
@@ -6,0 +6,0 @@ // `deleteProp` action cannot be executed on collections |
@@ -9,2 +9,2 @@ import type { PluginFetchAction } from '@magnetarjs/types'; | ||
[docPath: string]: undefined | 'error' | boolean; | ||
}, Vue3StoreOptions: Vue3StoreOptions): PluginFetchAction; | ||
}, vue3StoreOptions: Vue3StoreOptions): PluginFetchAction; |
@@ -5,3 +5,3 @@ import { filterDataPerClauses } from '@magnetarjs/utils'; | ||
import { insertActionFactory } from './insert.js'; | ||
export function fetchActionFactory(data, exists, Vue3StoreOptions) { | ||
export function fetchActionFactory(data, exists, vue3StoreOptions) { | ||
return function ({ payload, collectionPath, docId, actionConfig, pluginModuleConfig, }) { | ||
@@ -79,3 +79,3 @@ const force = payload?.force === true; | ||
return; | ||
insertActionFactory(data, Vue3StoreOptions)({ | ||
insertActionFactory(data, vue3StoreOptions)({ | ||
payload: _payload, | ||
@@ -82,0 +82,0 @@ collectionPath, |
@@ -5,2 +5,2 @@ import type { PathWhereIdentifier, PluginFetchCountAction } from '@magnetarjs/types'; | ||
[collectionPath in PathWhereIdentifier]?: number; | ||
}, Vue3StoreOptions: Vue3StoreOptions): PluginFetchCountAction; | ||
}, vue3StoreOptions: Vue3StoreOptions): PluginFetchCountAction; |
import { getPathWhereIdentifier } from '@magnetarjs/types'; | ||
export function fetchCountActionFactory(pathCountDic, Vue3StoreOptions) { | ||
export function fetchCountActionFactory(pathCountDic, vue3StoreOptions) { | ||
return function ({ collectionPath, actionConfig, pluginModuleConfig, }) { | ||
const pathId = getPathWhereIdentifier(collectionPath, pluginModuleConfig); | ||
const doOnFetchCountAction = ({ count }) => { | ||
const doOnFetchAggregateAction = (count) => { | ||
// abort updating local state if the payload was set to undefined | ||
@@ -11,4 +11,4 @@ if (count === undefined) | ||
}; | ||
return doOnFetchCountAction; | ||
return doOnFetchAggregateAction; | ||
}; | ||
} |
@@ -7,2 +7,2 @@ import type { PluginInsertAction } from '@magnetarjs/types'; | ||
}>; | ||
}, Vue3StoreOptions: Vue3StoreOptions, makeBackup?: MakeRestoreBackup): PluginInsertAction; | ||
}, vue3StoreOptions: Vue3StoreOptions, makeBackup?: MakeRestoreBackup): PluginInsertAction; |
import { objGetOrSet } from 'getorset-anything'; | ||
import { isFullString, isNumber } from 'is-what'; | ||
export function insertActionFactory(data, Vue3StoreOptions, makeBackup) { | ||
export function insertActionFactory(data, vue3StoreOptions, makeBackup) { | ||
return function ({ payload, collectionPath, docId, pluginModuleConfig, }) { | ||
@@ -11,3 +11,3 @@ const collectionMap = objGetOrSet(data, collectionPath, () => new Map()); | ||
? `${payload['id']}` | ||
: Vue3StoreOptions.generateRandomId()); | ||
: vue3StoreOptions.generateRandomId()); | ||
if (makeBackup) | ||
@@ -14,0 +14,0 @@ makeBackup(collectionPath, _docId); |
@@ -7,2 +7,2 @@ import type { PluginWriteAction } from '@magnetarjs/types'; | ||
}>; | ||
}, Vue3StoreOptions: Vue3StoreOptions, actionName: 'merge' | 'assign' | 'replace', makeBackup?: MakeRestoreBackup): PluginWriteAction; | ||
}, vue3StoreOptions: Vue3StoreOptions, actionName: 'merge' | 'assign' | 'replace', makeBackup?: MakeRestoreBackup): PluginWriteAction; |
import { objGetOrSet } from 'getorset-anything'; | ||
import { isPlainObject } from 'is-what'; | ||
import { merge } from 'merge-anything'; | ||
export function writeActionFactory(data, Vue3StoreOptions, actionName, makeBackup) { | ||
export function writeActionFactory(data, vue3StoreOptions, actionName, makeBackup) { | ||
return function ({ payload, collectionPath, docId, pluginModuleConfig, }) { | ||
@@ -6,0 +6,0 @@ // write actions cannot be executed on collections |
@@ -7,2 +7,2 @@ import type { PluginRevertAction } from '@magnetarjs/types'; | ||
}>; | ||
}, Vue3StoreOptions: Vue3StoreOptions, restoreBackup: MakeRestoreBackup): PluginRevertAction; | ||
}, vue3StoreOptions: Vue3StoreOptions, restoreBackup: MakeRestoreBackup): PluginRevertAction; |
@@ -1,2 +0,2 @@ | ||
export function revertActionFactory(data, Vue3StoreOptions, restoreBackup) { | ||
export function revertActionFactory(data, vue3StoreOptions, restoreBackup) { | ||
return function ({ payload, collectionPath, docId, pluginModuleConfig, actionName, error, }) { | ||
@@ -3,0 +3,0 @@ // revert all write actions when called on a doc |
@@ -7,2 +7,2 @@ import type { PluginStreamAction } from '@magnetarjs/types'; | ||
}>; | ||
}, Vue3StoreOptions: Vue3StoreOptions): PluginStreamAction; | ||
}, vue3StoreOptions: Vue3StoreOptions): PluginStreamAction; |
import { isFullString, isString } from 'is-what'; | ||
import { deleteActionFactory } from './delete.js'; | ||
import { insertActionFactory } from './insert.js'; | ||
export function streamActionFactory(data, Vue3StoreOptions) { | ||
export function streamActionFactory(data, vue3StoreOptions) { | ||
return function ({ payload, collectionPath, docId, actionConfig, pluginModuleConfig, mustExecuteOnRead, }) { | ||
@@ -13,3 +13,3 @@ // hover over the prop names below to see more info on when they are triggered: | ||
const _docId = docId || `${meta.id}`; | ||
insertActionFactory(data, Vue3StoreOptions)({ | ||
insertActionFactory(data, vue3StoreOptions)({ | ||
payload, | ||
@@ -28,3 +28,3 @@ collectionPath, | ||
const _docId = docId || `${meta.id}`; | ||
insertActionFactory(data, Vue3StoreOptions)({ | ||
insertActionFactory(data, vue3StoreOptions)({ | ||
payload, | ||
@@ -48,3 +48,3 @@ collectionPath, | ||
const [_cPath, _dId] = collectionPathDocIdToDelete; | ||
deleteActionFactory(data, Vue3StoreOptions)({ | ||
deleteActionFactory(data, vue3StoreOptions)({ | ||
payload: undefined, | ||
@@ -51,0 +51,0 @@ collectionPath: _cPath, |
@@ -11,2 +11,3 @@ import { getPathWhereIdentifier } from '@magnetarjs/types'; | ||
import { fetchActionFactory } from './actions/fetch.js'; | ||
import { fetchAggregateActionFactory } from './actions/fetchAggregate.js'; | ||
import { fetchCountActionFactory } from './actions/fetchCount.js'; | ||
@@ -28,2 +29,4 @@ import { insertActionFactory } from './actions/insert.js'; | ||
const pathCountDic = reactive({}); | ||
const pathSumDic = reactive({}); | ||
const pathAverageDic = reactive({}); | ||
const dataBackups = {}; | ||
@@ -119,2 +122,10 @@ const makeBackup = (collectionPath, docId) => { | ||
*/ | ||
const getModuleAggregate = (kind, { collectionPath, pluginModuleConfig = {}, }) => { | ||
const pathId = getPathWhereIdentifier(collectionPath, pluginModuleConfig); | ||
const dic = kind === 'sum' ? pathSumDic[pathId] : pathAverageDic[pathId]; | ||
return dic ?? {}; | ||
}; | ||
/** | ||
* This must be provided by Store Plugins that have "local" data. It is triggered EVERY TIME the module's count is accessed. | ||
*/ | ||
const getModuleCount = ({ collectionPath, pluginModuleConfig = {}, }) => { | ||
@@ -140,2 +151,4 @@ const pathId = getPathWhereIdentifier(collectionPath, pluginModuleConfig); | ||
const fetchCount = fetchCountActionFactory(pathCountDic, vue3StoreOptions); | ||
const fetchSum = fetchAggregateActionFactory(pathSumDic, vue3StoreOptions); | ||
const fetchAverage = fetchAggregateActionFactory(pathAverageDic, vue3StoreOptions); | ||
const stream = streamActionFactory(data, vue3StoreOptions); | ||
@@ -155,2 +168,4 @@ const insert = insertActionFactory(data, vue3StoreOptions, makeBackup); | ||
fetchCount, | ||
fetchSum, | ||
fetchAverage, | ||
stream, | ||
@@ -168,4 +183,5 @@ insert, | ||
getModuleCount, | ||
getModuleAggregate, | ||
}; | ||
return instance; | ||
}; |
{ | ||
"name": "@magnetarjs/plugin-vue3", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"type": "module", | ||
@@ -29,5 +29,6 @@ "sideEffects": false, | ||
"merge-anything": "^5.1.7", | ||
"nestify-anything": "^3.0.0", | ||
"path-to-prop": "2.0.4", | ||
"@magnetarjs/types": "1.0.1", | ||
"@magnetarjs/utils": "1.0.1" | ||
"@magnetarjs/types": "1.1.0", | ||
"@magnetarjs/utils": "1.1.0" | ||
}, | ||
@@ -34,0 +35,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
28922
24
562
1
10
+ Addednestify-anything@^3.0.0
+ Added@magnetarjs/types@1.1.0(transitive)
+ Added@magnetarjs/utils@1.1.0(transitive)
+ Addedmerge-anything@6.0.2(transitive)
+ Addednestify-anything@3.0.2(transitive)
- Removed@magnetarjs/types@1.0.1(transitive)
- Removed@magnetarjs/utils@1.0.1(transitive)
Updated@magnetarjs/types@1.1.0
Updated@magnetarjs/utils@1.1.0