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

mongochangestream

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongochangestream - npm Package Compare versions

Comparing version 0.30.0 to 0.31.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 0.31.0
- Explicit types for health check failure.
- Emit the following field to differentiate failure types:
`failureType` with values `initialScan` and `changeStream`.
# 0.30.0

@@ -2,0 +8,0 @@

18

dist/mongoChangeStream.js

@@ -92,3 +92,6 @@ "use strict";

debug('Health check failed - initial scan');
emit('healthCheckFail', { initialScan: true, lastSyncedAt });
emit('healthCheckFail', {
failureType: 'initialScan',
lastSyncedAt,
});
}

@@ -224,3 +227,3 @@ };

emit('healthCheckFail', {
changeStream: true,
failureType: 'changeStream',
lastRecordCreatedAt,

@@ -317,3 +320,7 @@ lastSyncedAt,

// Check for a cached schema
let previousSchema = await getCachedCollectionSchema().then((schema) => schema && maybeRemoveMetadata(schema));
let previousSchema = await getCachedCollectionSchema().then((schema) => {
if (schema) {
return maybeRemoveMetadata(schema);
}
});
if (!previousSchema) {

@@ -335,3 +342,6 @@ const schema = await getCollectionSchema(db).then(maybeRemoveMetadata);

// Emit change
emit('schemaChange', { previousSchema, currentSchema });
emit('schemaChange', {
previousSchema,
currentSchema,
});
// Previous schema is now the current schema

@@ -338,0 +348,0 @@ previousSchema = currentSchema;

@@ -32,3 +32,18 @@ import { ChangeStreamDocument, ChangeStreamInsertDocument, Document } from 'mongodb';

}
interface InitialScanFailEvent {
failureType: 'initialScan';
lastSyncedAt: number;
}
interface ChangeStreamFailEvent {
failureType: 'changeStream';
lastRecordCreatedAt: number;
lastSyncedAt: number;
}
export declare type HealthCheckFailEvent = InitialScanFailEvent | ChangeStreamFailEvent;
export interface SchemaChangeEvent {
previousSchema?: JSONSchema;
currentSchema: JSONSchema;
}
export declare type JSONSchema = Record<string, any>;
export declare type Events = 'schemaChange' | 'healthCheckFail';
export {};

@@ -15,3 +15,3 @@ import { Collection } from 'mongodb';

*/
export declare const removeMetadata: (schema: JSONSchema) => object;
export declare const removeMetadata: (schema: JSONSchema) => JSONSchema;
export declare function when<T, R>(condition: any, fn: (x: T) => R): (x: T) => T | R;
{
"name": "mongochangestream",
"version": "0.30.0",
"version": "0.31.0",
"description": "Sync MongoDB collections via change streams into any database.",

@@ -5,0 +5,0 @@ "author": "GovSpend",

@@ -19,2 +19,4 @@ import _ from 'lodash/fp.js'

JSONSchema,
HealthCheckFailEvent,
SchemaChangeEvent,
} from './types.js'

@@ -130,3 +132,6 @@ import _debug from 'debug'

debug('Health check failed - initial scan')
emit('healthCheckFail', { initialScan: true, lastSyncedAt })
emit('healthCheckFail', {
failureType: 'initialScan',
lastSyncedAt,
} as HealthCheckFailEvent)
}

@@ -285,6 +290,6 @@ }

emit('healthCheckFail', {
changeStream: true,
failureType: 'changeStream',
lastRecordCreatedAt,
lastSyncedAt,
})
} as HealthCheckFailEvent)
}

@@ -397,5 +402,7 @@ }

// Check for a cached schema
let previousSchema = await getCachedCollectionSchema().then(
(schema) => schema && maybeRemoveMetadata(schema)
)
let previousSchema = await getCachedCollectionSchema().then((schema) => {
if (schema) {
return maybeRemoveMetadata(schema)
}
})
if (!previousSchema) {

@@ -419,3 +426,6 @@ const schema = await getCollectionSchema(db).then(maybeRemoveMetadata)

// Emit change
emit('schemaChange', { previousSchema, currentSchema })
emit('schemaChange', {
previousSchema,
currentSchema,
} as SchemaChangeEvent)
// Previous schema is now the current schema

@@ -422,0 +432,0 @@ previousSchema = currentSchema

@@ -45,4 +45,22 @@ import {

interface InitialScanFailEvent {
failureType: 'initialScan'
lastSyncedAt: number
}
interface ChangeStreamFailEvent {
failureType: 'changeStream'
lastRecordCreatedAt: number
lastSyncedAt: number
}
export type HealthCheckFailEvent = InitialScanFailEvent | ChangeStreamFailEvent
export interface SchemaChangeEvent {
previousSchema?: JSONSchema
currentSchema: JSONSchema
}
export type JSONSchema = Record<string, any>
export type Events = 'schemaChange' | 'healthCheckFail'

@@ -39,3 +39,3 @@ import { Collection } from 'mongodb'

*/
export const removeMetadata = (schema: JSONSchema) => {
export const removeMetadata = (schema: JSONSchema): JSONSchema => {
const walkFn = ({ val }: Node) => {

@@ -42,0 +42,0 @@ if ('title' in val) {

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