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

@live-change/framework

Package Overview
Dependencies
Maintainers
1
Versions
362
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@live-change/framework - npm Package Compare versions

Comparing version 0.2.14 to 0.2.15

lib/definition/ForeignIndexDefinition.js

2

lib/App.js

@@ -170,3 +170,3 @@ const ReactiveDao = require("@live-change/dao")

for(const route of routes) {
promises.push(this.triggerService(route.service, data))
promises.push(this.triggerService(route.service, { ...data }))
}

@@ -173,0 +173,0 @@ return Promise.all(promises)

@@ -34,2 +34,14 @@ const PropertyDefinition = require("./PropertyDefinition.js")

}
let indexes
if(this.indexes) {
indexes = {}
for(let indexName in this.indexes) {
indexes[indexName] = {
...this.indexes[indexName]
}
if(this.indexes[indexName].function) {
indexes[indexName].function = `${this.indexes[indexName].function}`
}
}
}
return {

@@ -45,5 +57,6 @@ ... this,

let changes = []
changes.push(...utils.crudChanges(oldModel.properties || {}, this.properties || {},
const json = this.toJSON()
changes.push(...utils.crudChanges(oldModel.properties || {}, json.properties || {},
"Property", "property", { model: this.name }))
changes.push(...utils.crudChanges(oldModel.indexes || {}, this.indexes || {},
changes.push(...utils.crudChanges(oldModel.indexes || {}, json.indexes || {},
"Index", "index", { model: this.name }))

@@ -50,0 +63,0 @@ if(oldModel.search && !this.search) changes.push({ operation: "searchDisabled", model: this.name })

const ModelDefinition = require("./ModelDefinition.js")
const ForeignModelDefinition = require("./ForeignModelDefinition.js")
const IndexDefinition = require("./IndexDefinition.js")
const ForeignIndexDefinition = require("./ForeignIndexDefinition.js")
const ActionDefinition = require("./ActionDefinition.js")

@@ -40,2 +42,32 @@ const TriggerDefinition = require("./TriggerDefinition.js")

function createIndexProxy(definition, model) {
return new Proxy(model, {
get(target, prop, receiver) {
const runtime = definition._runtime
if(runtime) {
const indexRuntime = runtime.indexes[model.name]
if(indexRuntime[prop]) {
return Reflect.get(indexRuntime, prop, receiver)
}
}
return Reflect.get(target, prop, receiver)
}
})
}
function createForeignIndexProxy(definition, model) {
return new Proxy(model, {
get(target, prop, receiver) {
const runtime = definition._runtime
if(runtime) {
const indexRuntime = runtime.foreignIndexes[model.name]
if(indexRuntime[prop]) {
return Reflect.get(indexRuntime, prop, receiver)
}
}
return Reflect.get(target, prop, receiver)
}
})
}
class ServiceDefinition {

@@ -45,6 +77,8 @@

this.models = {}
this.foreignModels = {}
this.indexes = {}
this.foreignIndexes = {}
this.actions = {}
this.views = {}
this.events = {}
this.foreignModels = {}
this.triggers = {}

@@ -60,3 +94,21 @@ this.validators = {}

}
foreignModel(serviceName, modelName) {
const model = new ForeignModelDefinition(serviceName, modelName)
this.foreignModels[serviceName + "_" + modelName] = model
return createForeignModelProxy(this, model)
}
index(definition) {
const index = new IndexDefinition(definition)
this.indexes[index.name] = index
return createIndexProxy(this, model)
}
foreignIndex(serviceName, indexName) {
const index = new ForeignIndexDefinition(serviceName, indexName)
this.foreignIndexes[serviceName + "_" + indexName] = index
return createForeignIndexProxy(this, index)
}
action(definition) {

@@ -86,8 +138,2 @@ const action = new ActionDefinition(definition)

foreignModel(serviceName, modelName) {
const model = new ForeignModelDefinition(serviceName, modelName)
this.foreignModels[serviceName + "_" + modelName] = model
return createForeignModelProxy(this, model)
}
toJSON() {

@@ -98,2 +144,6 @@ let models = {}

for(let key in this.foreignModels) foreignModels[key] = this.foreignModels[key].toJSON()
let indexes = {}
for(let key in this.indexes) indexes[key] = this.indexes[key].toJSON()
let foreignIndexes = {}
for(let key in this.foreignIndexes) foreignIndexes[key] = this.foreignIndexes[key].toJSON()
let actions = {}

@@ -112,2 +162,4 @@ for(let key in this.actions) actions[key] = this.actions[key].toJSON()

foreignModels,
indexes,
foreignIndexes,
actions,

@@ -114,0 +166,0 @@ views,

@@ -32,2 +32,3 @@ const ReactiveDao = require("@live-change/dao")

return ['database', 'query', this.service.databaseName, `(${
/// TODO: observe objects
async (input, output, { tableName, indexName, range }) => {

@@ -49,2 +50,3 @@ const mapper = async (res) => input.table(tableName).object(res.to).get()

return ['database', 'queryObject', this.service.databaseName, `(${
/// TODO: observe object
async (input, output, { tableName, indexName, range }) => {

@@ -51,0 +53,0 @@ const mapper = async (res) => input.table(tableName).object(res.to).get()

const Model = require("./Model.js")
const ForeignModel = require("./ForeignModel.js")
const Index = require("./Index.js")
const View = require("./View.js")

@@ -31,2 +32,14 @@ const Action = require("./Action.js")

this.indexes = {}
for(let indexName in this.definition.indexes) {
this.indexes[indexName] = new Index( this.name, this.definition.indexes[indexName].name, this )
}
this.foreignIndexes = {}
for(let indexName in this.definition.indexes) {
const defn = this.definition.indexes[indexName]
this.foreignIndexes[indexName] =
new Index( defn.serviceName, defn.indexName , this )
}
this.views = {}

@@ -33,0 +46,0 @@ for(let viewName in this.definition.views) {

{
"name": "@live-change/framework",
"version": "0.2.14",
"version": "0.2.15",
"description": "Live Change Framework - ultimate solution for real time mobile/web apps",

@@ -5,0 +5,0 @@ "main": "index.js",

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