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

@travetto/schema

Package Overview
Dependencies
Maintainers
1
Versions
323
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/schema - npm Package Compare versions

Comparing version 0.0.23 to 0.0.24

test/index.js

2

package.json

@@ -28,3 +28,3 @@ {

},
"version": "0.0.23"
"version": "0.0.24"
}

@@ -128,43 +128,43 @@ import { ClassList, FieldConfig, ClassConfig, ViewConfig } from './types';

onFieldChange<T>(callback: (e: ChangeEvent<FieldConfig>) => any): void {
this.events.on('field:change', callback);
}
emitFieldDelta(cls: Class) {
const prev = this.getExpired(cls);
const curr = this.get(cls);
emitFieldChange(ev: ChangeEvent<FieldConfig>) {
this.events.emit('field:change', ev);
}
const prevView = prev.views[this.DEFAULT_VIEW];
const currView = curr.views[this.DEFAULT_VIEW];
computeFieldDelta(cls: Class) {
const previous = this.getExpired(cls);
const current = this.get(cls);
if (previous && current) {
const prevView = previous.views[this.DEFAULT_VIEW];
const currView = current.views[this.DEFAULT_VIEW];
const prevFields = new Set(prevView.fields);
const currFields = new Set(currView.fields);
const prevFields = new Set(prevView.fields);
const currFields = new Set(currView.fields);
for (const c of currFields) {
if (!prevFields.has(c)) {
this.emitFieldChange({ curr: currView.schema[c], type: 'added' });
}
const changes: ChangeEvent<FieldConfig>[] = [];
for (const c of currFields) {
if (!prevFields.has(c)) {
changes.push({ curr: currView.schema[c], type: 'added' });
}
}
for (const c of prevFields) {
if (!currFields.has(c)) {
this.emitFieldChange({ prev: prevView.schema[c], type: 'removing' });
}
for (const c of prevFields) {
if (!currFields.has(c)) {
changes.push({ prev: prevView.schema[c], type: 'removing' });
}
}
for (const c of currFields) {
if (prevFields.has(c)) {
const { type, ...prevSchema } = prevView.schema[c];
const { type: type2, ...currSchema } = currView.schema[c];
if (JSON.stringify(prevSchema) !== JSON.stringify(currSchema)) {
this.emitFieldChange({ prev: prevView.schema[c], curr: currView.schema[c], type: 'changed' });
}
for (const c of currFields) {
if (prevFields.has(c)) {
const { type, ...prevSchema } = prevView.schema[c];
const { type: type2, ...currSchema } = currView.schema[c];
if (JSON.stringify(prevSchema) !== JSON.stringify(currSchema)) {
changes.push({ prev: prevView.schema[c], curr: currView.schema[c], type: 'changed' });
}
}
}
this.events.emit('field:change', { cls, changes });
}
onFieldChange<T>(callback: (e: { cls: Class, changes: ChangeEvent<FieldConfig>[] }) => any): void {
this.events.on('field:change', callback);
}
onInstallFinalize(cls: Class) {

@@ -189,8 +189,13 @@

this.computeFieldDelta(cls);
return config;
}
emit(ev: ChangeEvent<Class>) {
super.emit(ev);
if (ev.type === 'changed') {
this.emitFieldDelta(ev.curr!);
}
}
}
export const SchemaRegistry = new $SchemaRegistry();
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