@live-change/framework
Advanced tools
Comparing version 0.8.51 to 0.8.52
@@ -326,3 +326,3 @@ import {randomString, uidGenerator} from '@live-change/uid' | ||
const action = service.actions[data.type] | ||
const reportFinished = action.definition.waitForEvents ? 'command_' + command.id : undefined | ||
const reportFinished = action.definition.waitForEvents ? command.id : undefined | ||
const flags = {commandId: command.id, reportFinished} | ||
@@ -462,6 +462,5 @@ const emit = (!this.splitEvents || this.shortEvents) | ||
const [action, id] = reportId.split('_') | ||
const triggerId = action === 'trigger' ? id : undefined | ||
const commandId = action === 'command' ? id : undefined | ||
const commandId = id | ||
const profileOp = await this.profileLog.begin({ | ||
operation: "waitForEvents", action: action, commandId, triggerId, reportId, events, timeout | ||
operation: "waitForEvents", action: action, commandId, reportId, events, timeout | ||
}) | ||
@@ -529,2 +528,8 @@ const promise = new Promise((resolve, reject) => { | ||
async emitEventsAndWait(service, events, flags = {}) { | ||
const reportId = 'trigger_' + this.generateUid() | ||
await this.emitEvents(service, events, { reportFinished: reportId, ...flags }) | ||
return await this.waitForEvents(reportId, events) | ||
} | ||
async assertTime(taskName, duration, task, ...data) { | ||
@@ -531,0 +536,0 @@ const profileOp = await this.profileLog.begin({ operation: 'assertTime', taskName }) |
@@ -88,2 +88,3 @@ import ModelDefinition from "./ModelDefinition.js" | ||
this.beforeStartCallbacks = [] | ||
this.afterStartCallbacks = [] | ||
this.endpoints = [] | ||
@@ -162,2 +163,6 @@ this.validators = { ...defaultValidators } | ||
afterStart(callback) { | ||
this.afterStartCallbacks.push(callback) | ||
} | ||
endpoint(endpoint) { | ||
@@ -164,0 +169,0 @@ this.endpoints.push(endpoint) |
@@ -29,3 +29,3 @@ import KeyBasedExecutionQueues from '../utils/KeyBasedExecutionQueues.js'; | ||
const reportFinished = action.definition.waitForEvents ? 'command_' + command.id : undefined | ||
const flags = {commandId: command.id, reportFinished} | ||
const flags = { commandId: command.id, reportFinished } | ||
const emit = (!service.app.splitEvents || this.shortEvents) | ||
@@ -32,0 +32,0 @@ ? new SingleEmitQueue(service, flags) |
@@ -96,2 +96,10 @@ import Model from "./Model.js" | ||
async afterStart(config){ | ||
if(config.runCommands) { | ||
for (const afterStartCallback of this.definition.afterStartCallbacks) { | ||
await afterStartCallback(this) | ||
} | ||
} | ||
} | ||
async trigger(trigger, data) { | ||
@@ -98,0 +106,0 @@ return this.app.trigger({ |
@@ -98,5 +98,2 @@ import ReactiveDao from '@live-change/dao' | ||
} | ||
console.log("UPDATE DATABASE", ['database', 'update'], this.database, this.tableName, command.id, [ | ||
{ op: 'merge', property: null, value: { state: 'done', result, stats } } | ||
]) | ||
await this.connection.request(['database', 'update'], this.database, this.tableName, command.id, [ | ||
@@ -103,0 +100,0 @@ { op: 'merge', property: null, value: { state: 'done', result, stats } } |
@@ -29,3 +29,3 @@ | ||
if(this.commited) { | ||
if(events.length == 0) return | ||
if(events.length === 0) return | ||
this.service.dao.request(['database', 'putLog'], this.service.databaseName, | ||
@@ -38,3 +38,3 @@ 'events', { type: 'bucket', events, ...this.flags }) | ||
this.commited = true | ||
if(this.emittedEvents.length == 0) return [] | ||
if(this.emittedEvents.length === 0) return [] | ||
await this.service.dao.request(['database', 'putLog'], this.service.databaseName, | ||
@@ -41,0 +41,0 @@ 'events', { type: 'bucket', events: this.emittedEvents, ...this.flags }) |
@@ -46,3 +46,3 @@ | ||
if(this.commited) { | ||
if(events.length == 0) return | ||
if(events.length === 0) return | ||
this.service.dao.request(['database', 'putLog'], this.service.databaseName, | ||
@@ -56,3 +56,3 @@ this.service.name+'_events', { type: 'bucket', events, ...this.flags }) | ||
this.commited = true | ||
if(this.emittedEvents.length == 0) return [] | ||
if(this.emittedEvents.length === 0) return [] | ||
let allEvents = [] | ||
@@ -59,0 +59,0 @@ for(const [service, events] of this.emittedEvents.keys()) { |
{ | ||
"name": "@live-change/framework", | ||
"version": "0.8.51", | ||
"version": "0.8.52", | ||
"description": "Live Change Framework - ultimate solution for real time mobile/web apps", | ||
@@ -25,6 +25,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@live-change/dao": "^0.8.51", | ||
"@live-change/uid": "^0.8.51" | ||
"@live-change/dao": "^0.8.52", | ||
"@live-change/uid": "^0.8.52" | ||
}, | ||
"gitHead": "ba8da813894eeb717223aa8d5e364649e4ac0347" | ||
"gitHead": "d06ad62415cc92e15b5dee87078614d4f883eb83" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186698
5085