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

clockvine

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clockvine - npm Package Compare versions

Comparing version

to
2.0.0-alpha.5

2

package.json
{
"name": "clockvine",
"version": "2.0.0-alpha.4",
"version": "2.0.0-alpha.5",
"description": "",

@@ -5,0 +5,0 @@ "author": "Kevin Hamer [kh] <kevin@imarc.com>",

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

import { unref, isRef, isReactive } from 'vue'
const filterKeys = (obj, remove = [null, undefined]) => {

@@ -6,12 +8,13 @@ return Object.fromEntries(Object.entries(obj).filter(([_, v]) => !remove.includes(v)))

export default function DefaultUrlFormatter (baseUrl) {
this.format = (action, queryParams) => {
if (['show', 'update', 'destroy'].includes(action) && 'id' in queryParams) {
baseUrl = baseUrl.replace(/(\.json)?$/, `/${queryParams.id}$1`)
delete queryParams.id
this.format = (action, queryParams, payload) => {
const id = queryParams?.id || payload?.id
if (['show', 'update', 'destroy'].includes(action) && ![null, undefined].includes(id)) {
const url = baseUrl.replace(/(\.json)?$/, `/${id}$1`)
const queryString = new URLSearchParams(filterKeys({ ...queryParams, id: undefined }))
return url + (String(queryString) ? '?' + String(queryString) : '')
}
const queryString = new URLSearchParams(filterKeys(queryParams))
return `${baseUrl}${String(queryString) ? '?' + queryString : ''}`
}
}

@@ -86,2 +86,5 @@ import { defineStore } from 'pinia'

const mergeElements = elements => {
if (!elements.map) {
console.error('elements.map not defined', elements)
}
return elements.map(element => mergeElement(element[idField], element))

@@ -214,4 +217,4 @@ }

const update = async element => {
const updatedElement = await api.update(element)
const update = async (element, params = {}) => {
const updatedElement = await api.update(nestedUnref(element), params)
const id = idField in updatedElement ? updatedElement[idField] : element[idField]

@@ -222,4 +225,4 @@ invalidateAllIndexes()

const destroy = async element => {
const deletedElement = await api.destroy(element)
const destroy = async (element, params = {}) => {
const deletedElement = await api.destroy(nestedUnref(element), params)
invalidateAllIndexes()

@@ -226,0 +229,0 @@ return deleteElement(deletedElement)

@@ -32,2 +32,26 @@ import DefaultUrlFormatter from './DefaultUrlFormatter.js'

}
this.update = async function (element, params = {}) {
const url = createQueryUrl('update', params, element)
const options = {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(element)
}
return fetch(url, options).then(r => r.json()).then(r => r.data)
}
this.destroy = async function (element, params = {}) {
const url = createQueryUrl('destroy', params, element)
const options = {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(element)
}
return fetch(url, options).then(r => r.json()).then(r => r.data)
}
}