@live-change/framework 0.8.110 → 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
@@ -15,7 +15,7 @@ import ApiServer from "./runtime/ApiServer.js"
15
15
 
16
16
  import reverseRelationProcessor from "./processors/reverseRelation.js"
17
17
  import indexListProcessor from "./processors/indexList.js"
18
- import crudGenerator from "./processors/crudGenerator.js"
18
+ //import crudGenerator from "./processors/crudGenerator.js"
19
19
  import draftGenerator from "./processors/draftGenerator.js"
20
20
  import daoPathView from "./processors/daoPathView.js"
21
21
  import fetchView from "./processors/fetchView.js"
@@ -51,7 +51,7 @@ class App {
51
51
  this.requestTimeout = config?.db?.requestTimeout || 10*1000
52
52
 
53
53
  this.defaultProcessors = [
54
- crudGenerator,
54
+ // crudGenerator,
55
55
  draftGenerator,
56
56
  reverseRelationProcessor,
57
57
  indexListProcessor,
@@ -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.110",
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.110",
26
- "@live-change/uid": "^0.8.110"
25
+ "@live-change/dao": "^0.8.112",
26
+ "@live-change/uid": "^0.8.112"
27
27
  },
28
- "gitHead": "8af31d640f43b00b2874f2c70fa4d4486541adfe"
28
+ "gitHead": "e0d0db33777f8f9fc9f5ebe1a977cf574b837be6"
29
29
  }