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

@live-change/relations-plugin

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@live-change/relations-plugin - npm Package Compare versions

Comparing version 0.1.13 to 0.1.14

15

itemEvents.js

@@ -30,2 +30,15 @@

function defineTransferredEvent(config, context) {
const {
service, modelRuntime, joinedOthersPropertyName, modelName, modelPropertyName
} = context
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Transferred'
service.events[eventName] = new EventDefinition({
name: eventName,
execute(properties) {
const id = properties[modelPropertyName]
return modelRuntime().update(id, { ...properties.to, id })
}
})
}

@@ -46,2 +59,2 @@ function defineDeletedEvent(config, context) {

module.exports = { defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent }
module.exports = { defineCreatedEvent, defineUpdatedEvent, defineTransferredEvent, defineDeletedEvent }

4

itemOf.js

@@ -44,4 +44,5 @@ const App = require("@live-change/framework")

const {
defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent
defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent, defineTransferredEvent,
} = require('itemEvents.js')
const {defineTransferEvent} = require("./itemEvents");

@@ -184,2 +185,3 @@ function defineCreateAction(config, context) {

defineUpdatedEvent(config, context)
defineTransferredEvent(config, context)
defineDeletedEvent(config, context)

@@ -186,0 +188,0 @@

@@ -52,4 +52,5 @@ const App = require("@live-change/framework")

const {
defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent
defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent, defineTransferredEvent,
} = require('itemEvents.js')
const {defineTransferEvent} = require("./itemEvents");

@@ -106,3 +107,3 @@ function defineCreateAction(config, context) {

waitForEvents: true,
async execute(properties, {client, service}, emit) {
async execute(properties, { client, service }, emit) {
const id = properties[modelPropertyName]

@@ -147,3 +148,3 @@ const entity = await modelRuntime().get(id)

waitForEvents: true,
async execute(properties, {client, service}, emit) {
async execute(properties, { client, service }, emit) {
const id = properties[modelPropertyName]

@@ -168,3 +169,3 @@ const entity = await modelRuntime().get(id)

console.log("DEFINE SORT INDEX", sortFields)
const sortFieldsUc = sortFields.map(fd=>fd.slice(0, 1).toUpperCase() + fd.slice(1))
const sortFieldsUc = sortFields.map(fd => fd.slice(0, 1).toUpperCase() + fd.slice(1))
const indexName = 'by' + context.joinedOthersClassName + sortFieldsUc.join('')

@@ -195,2 +196,3 @@ context.model.indexes[indexName] = new IndexDefinition({

defineUpdatedEvent(config, context)
defineTransferredEvent(config, context)
defineDeletedEvent(config, context)

@@ -197,0 +199,0 @@

{
"name": "@live-change/relations-plugin",
"version": "0.1.13",
"version": "0.1.14",
"description": "",

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

@@ -1,4 +0,4 @@

const { generateAnyId } = require("./utilsAny.js");
function defineSetEvent(config, context) {
function defineSetEvent(config, context, generateId) {
const {

@@ -17,3 +17,3 @@ service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames

function defineUpdateEvent(config, context) {
function defineUpdatedEvent(config, context, generateId) {
const {

@@ -27,3 +27,3 @@ service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames

const id = generateId(otherPropertyNames, properties.identifiers)
return modelRuntime().update(id, { ...properties.data, ...properties.identifiers })
return modelRuntime().update(id, { ...properties.data, /*...properties.identifiers*/ })
}

@@ -33,6 +33,28 @@ })

function defineResetEvent(config, context) {
function defineTransferredEvent(config, context, generateId) {
const {
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames
} = context
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Transferred'
service.events[eventName] = new EventDefinition({
name: eventName,
async execute(properties) {
const fromId = generateId(otherPropertyNames, properties.from)
const toId = generateId(otherPropertyNames, properties.to)
const data = await modelRuntime().get(fromId)
await modelRuntime().create({
...data,
...properties.to,
id: toId
})
await modelRunntime().delete(fromId)
return toId
}
})
}
function defineResetEvent(config, context, generateId) {
const {
service, modelRuntime, joinedOthersPropertyName, modelName, otherPropertyNames
} = context
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Reset'

@@ -48,2 +70,2 @@ service.events[eventName] = new EventDefinition({

module.exports = { defineSetEvent, defineUpdateEvent, defineResetEvent }
module.exports = { defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent }

@@ -40,3 +40,3 @@ const App = require("@live-change/framework")

const { defineSetEvent, defineUpdateEvent, defineResetEvent } = require('./propertyEvents.js')
const { defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent } = require('./propertyEvents.js')

@@ -154,5 +154,6 @@ function defineSetAction(config, context) {

defineSetEvent(config, context)
defineUpdateEvent(config, context)
defineResetEvent(config, context)
defineSetEvent(config, context, generateId)
defineUpdateEvent(config, context, generateId)
defineTransferEvent(config, context, generateId)
defineResetEvent(config, context, generateId)

@@ -159,0 +160,0 @@ if(config.setAccess || config.writeAccess) {

@@ -5,3 +5,3 @@ const App = require("@live-change/framework")

const {
extractObjectData
extractObjectData, generateId
} = require('./utils.js')

@@ -49,3 +49,3 @@

const { defineSetEvent, defineUpdateEvent, defineResetEvent } = require('./propertyEvents.js')
const { defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent } = require('./propertyEvents.js')

@@ -163,5 +163,6 @@ function defineSetAction(config, context) {

defineSetEvent(config, context)
defineUpdateEvent(config, context)
defineResetEvent(config, context)
defineSetEvent(config, context, generateAnyId)
defineUpdatedEvent(config, context, generateAnyId)
defineTransferedEvent(config, context, generateId)
defineResetEvent(config, context, generateAnyId)

@@ -168,0 +169,0 @@ if(config.setAccess || config.writeAccess) {

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