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

blue-cot

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blue-cot - npm Package Compare versions

Comparing version 9.0.3 to 9.0.4

24

lib/db_handle.ts

@@ -6,3 +6,3 @@ import querystring from 'node:querystring'

import type { CreateIndexRequest, CreateIndexResponse, DatabaseChangesParams, DatabaseChangesResponse, Document, DocumentBulkResponse, DocumentDestroyResponse, DocumentFetchResponse, DocumentGetResponse, DocumentInsertParams, DocumentInsertResponse, DocumentLookupFailure, DocumentViewQuery, DocumentViewResponse, IdentifiedDocument, InfoResponse, MangoResponse } from '../types/nano.js'
import type { DocId, DocRev, DocTranformer, FetchOptions, FindOptions, FindQuery, JsonRequest, NewDoc, TestFunction, RecoveredDoc, UpdateOptions, ViewKey, DocumentDeletedFailure, RevInfo, DocumentRevertResponse, DocumentViewKeysQuery, ViewValue } from 'types/types.js'
import type { DocTranformer, FetchOptions, FindOptions, FindQuery, JsonRequest, NewDoc, TestFunction, RecoveredDoc, UpdateOptions, ViewKey, DocumentDeletedFailure, RevInfo, DocumentRevertResponse, DocumentViewKeysQuery, ViewValue } from 'types/types.js'

@@ -13,3 +13,3 @@ export default function (jsonRequest: JsonRequest, dbName: string) {

const db = {
docUrl: (docId: DocId) => {
docUrl: <D extends Document = Document> (docId: D['_id']) => {
validateString(docId, 'doc id')

@@ -28,3 +28,3 @@ if (docId.indexOf('_design/') === 0) {

get: async <D> (docId: DocId, docRev?: DocRev) => {
get: async <D extends Document = Document> (docId: D['_id'], docRev?: D['_rev']) => {
let url = db.docUrl(docId)

@@ -37,3 +37,3 @@ if (typeof docRev === 'string') url += `?rev=${docRev}`

exists: async (docId: DocId) => {
exists: async <D extends Document = Document> (docId: D['_id']) => {
try {

@@ -70,3 +70,3 @@ const res = await jsonRequest<DocumentGetResponse>('GET', db.docUrl(docId))

update: async (docId: DocId, fn: DocTranformer, options: UpdateOptions = {}): Promise<DocumentInsertResponse> => {
update: async <D extends Document = Document> (docId: D['_id'], fn: DocTranformer<D>, options: UpdateOptions = {}): Promise<DocumentInsertResponse> => {
let attempt = 0

@@ -95,3 +95,3 @@ const { createIfMissing } = options

delete: async (docId: DocId, rev: DocRev) => {
delete: async <D extends Document = Document> (docId: D['_id'], rev: D['_rev']) => {
validateString(rev, 'rev')

@@ -105,3 +105,3 @@ const url = db.docUrl(docId) + '?rev=' + encodeURIComponent(rev)

// Based on http://stackoverflow.com/a/16827094/3324977
undelete: async (docId: DocId) => {
undelete: async <D extends Document = Document> (docId: D['_id']) => {
validateString(docId, 'doc id')

@@ -127,3 +127,3 @@ try {

bulk: async (docs: Document[]) => {
bulk: async <D extends Document = Document> (docs: D[]) => {
validateArray(docs, 'docs')

@@ -215,3 +215,3 @@ const url = `/${dbName}/_bulk_docs`

listRevs: async (docId: DocId) => {
listRevs: async <D extends Document = Document> (docId: D['_id']) => {
const url = db.docUrl(docId) + '?revs_info=true'

@@ -222,3 +222,3 @@ const res = await jsonRequest<DocumentGetResponse>('GET', url)

revertLastChange: async (docId: DocId) => {
revertLastChange: async <D extends Document = Document> (docId: D['_id']) => {
const revsInfo = await db.listRevs(docId)

@@ -231,3 +231,3 @@ const currentRevInfo = revsInfo[0]

revertToLastVersionWhere: async (docId: DocId, testFn: TestFunction) => {
revertToLastVersionWhere: async <D extends Document = Document> (docId: D['_id'], testFn: TestFunction<D>) => {
const revsInfo = await db.listRevs(docId)

@@ -272,3 +272,3 @@ const currentRevInfo = revsInfo[0]

recover: async (docId: DocId, candidatesRevsInfo: RevInfo[], currentRevInfo: RevInfo, testFn?: TestFunction) => {
recover: async <D extends Document = Document> (docId: D['_id'], candidatesRevsInfo: RevInfo[], currentRevInfo: RevInfo, testFn?: TestFunction) => {
const previousRevInfo = candidatesRevsInfo.shift()

@@ -275,0 +275,0 @@

@@ -30,3 +30,3 @@ {

],
"version": "9.0.3",
"version": "9.0.4",
"main": "dist/lib/cot.js",

@@ -33,0 +33,0 @@ "dependencies": {

@@ -19,3 +19,3 @@ import type { Document, DocumentInsertResponse, DocumentViewQuery } from './nano.js'

export type DocTranformer = (doc: Document) => Document
export type DocTranformer <D extends Document = Document> = (doc: D) => D

@@ -45,3 +45,3 @@ export interface UpdateOptions {

export type TestFunction = (doc: Document) => boolean
export type TestFunction <D extends Document = Document> = (doc: D) => boolean

@@ -48,0 +48,0 @@ export interface API {

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