@live-change/framework 0.8.111 → 0.8.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/App.js CHANGED
@@ -291,9 +291,11 @@ class App {
291
291
  ['database', 'tableObject', this.databaseName, triggersTable, trigger.id],
292
292
  ReactiveDao.ObservableValue
293
293
  )
294
- await this.dao.request(['database', 'update', this.databaseName, triggersTable, trigger.id, [
295
- { op: 'reverseMerge', value: trigger }
296
- ]])
294
+ await this.dao.request(['database', 'update', this.databaseName, triggersTable, trigger.id, [{
295
+ op: 'conditional',
296
+ conditions: [{ test: 'notExist', property: 'type' }],
297
+ operations: [{ op: 'reverseMerge', value: trigger }],
298
+ }]])
297
299
  let observer
298
300
  const promise = new Promise((resolve, reject) => {
299
301
  observer = (signal, value) => {
@@ -396,9 +398,11 @@ class App {
396
398
  ['database', 'tableObject', this.databaseName, commandsTable, data.id],
397
399
  ReactiveDao.ObservableValue
398
400
  )
399
- await this.dao.request(['database', 'update', this.databaseName, commandsTable, data.id, [
400
- {op: 'reverseMerge', value: data}
401
- ]])
401
+ await this.dao.request(['database', 'update', this.databaseName, commandsTable, data.id, [{
402
+ op: 'conditional',
403
+ conditions: [{ test: 'notExist', property: 'type' }],
404
+ operations: [{ op: 'reverseMerge', value: data }],
405
+ }]])
402
406
  let observer
403
407
  const promise = new Promise((resolve, reject) => {
404
408
  observer = (signal, value) => {
@@ -3,15 +3,29 @@ import { getValidators, validate } from '../utils/validation.js'
3
3
  export default function(service, app) {
4
4
  for(let actionName in service.actions) {
5
5
  const action = service.actions[actionName]
6
- if(action.skipValidation) continue
6
+ if(action.skipValidation && !action.validation) continue
7
7
  const validators = getValidators(action, service, action)
8
8
  if(Object.keys(validators).length > 0) {
9
9
  const oldExec = action.execute
10
10
  action.execute = async (...args) => {
11
11
  const context = args[1]
12
- return validate(args[0], validators, { source: action, action, service, app, ...context }).then(() =>
13
- oldExec.apply(action, args)
14
- )
12
+ if(args[0]._validationOnly) {
13
+ if(!action.skipValidation) {
14
+ await validate(args[0], validators, { source: action, action, service, app, ...context })
15
+ }
16
+ if(action.validation === true) {
17
+ return await oldExec.apply(action, args) // validate inside execute
18
+ } else if(typeof action.validation === 'function') {
19
+ const result = await action.validation(args[0], { source: action, action, service, app, ...context })
20
+ if(result) throw result
21
+ return 'ok'
22
+ }
23
+ } else {
24
+ if(!action.skipValidation) {
25
+ await validate(args[0], validators, { source: action, action, service, app, ...context })
26
+ }
27
+ return oldExec.apply(action, args)
28
+ }
15
29
  }
16
30
  }
17
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/framework",
3
- "version": "0.8.111",
3
+ "version": "0.8.112",
4
4
  "description": "Live Change Framework - ultimate solution for real time mobile/web apps",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "homepage": "https://github.com/live-change/live-change-stack",
24
24
  "devDependencies": {
25
- "@live-change/dao": "^0.8.111",
26
- "@live-change/uid": "^0.8.111"
25
+ "@live-change/dao": "^0.8.112",
26
+ "@live-change/uid": "^0.8.112"
27
27
  },
28
- "gitHead": "9b96afb2fc61ab3d2a5d143924e2c56d411280b4"
28
+ "gitHead": "e0d0db33777f8f9fc9f5ebe1a977cf574b837be6"
29
29
  }