@live-change/framework 0.7.39 → 0.8.1

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.
Files changed (57) hide show
  1. package/index.js +34 -20
  2. package/lib/App.js +31 -31
  3. package/lib/clientSideFilters/accessFilter.js +2 -2
  4. package/lib/clientSideFilters/clientSideFilter.js +1 -1
  5. package/lib/definition/ActionDefinition.js +2 -3
  6. package/lib/definition/EventDefinition.js +2 -3
  7. package/lib/definition/ForeignIndexDefinition.js +1 -2
  8. package/lib/definition/ForeignModelDefinition.js +1 -3
  9. package/lib/definition/IndexDefinition.js +1 -5
  10. package/lib/definition/ModelDefinition.js +5 -7
  11. package/lib/definition/PropertyDefinition.js +5 -5
  12. package/lib/definition/ServiceDefinition.js +13 -13
  13. package/lib/definition/TriggerDefinition.js +2 -2
  14. package/lib/definition/ViewDefinition.js +2 -2
  15. package/lib/processes/commandExecutor.js +5 -5
  16. package/lib/processes/eventListener.js +2 -2
  17. package/lib/processes/triggerExecutor.js +5 -5
  18. package/lib/processors/accessControl.js +2 -2
  19. package/lib/processors/accessMethod.js +1 -3
  20. package/lib/processors/autoValidation.js +2 -2
  21. package/lib/processors/crudGenerator.js +2 -2
  22. package/lib/processors/daoPathView.js +2 -2
  23. package/lib/processors/draftGenerator.js +2 -2
  24. package/lib/processors/fetchView.js +2 -2
  25. package/lib/processors/indexCode.js +1 -2
  26. package/lib/processors/indexList.js +2 -2
  27. package/lib/processors/reverseRelation.js +2 -2
  28. package/lib/runtime/Action.js +2 -2
  29. package/lib/runtime/ApiServer.js +5 -5
  30. package/lib/runtime/Dao.js +3 -3
  31. package/lib/runtime/EventHandler.js +2 -2
  32. package/lib/runtime/ForeignModel.js +2 -2
  33. package/lib/runtime/Index.js +4 -4
  34. package/lib/runtime/LiveDao.js +4 -4
  35. package/lib/runtime/Model.js +6 -8
  36. package/lib/runtime/ReaderModel.js +19 -19
  37. package/lib/runtime/SearchIndexer.js +1 -3
  38. package/lib/runtime/Service.js +9 -9
  39. package/lib/runtime/SessionDao.js +4 -4
  40. package/lib/runtime/TriggerHandler.js +4 -4
  41. package/lib/runtime/View.js +4 -4
  42. package/lib/runtime/params.js +3 -4
  43. package/lib/runtime/utils.js +2 -6
  44. package/lib/updaters/database.js +4 -3
  45. package/lib/utils/CommandQueue.js +2 -2
  46. package/lib/utils/EventSourcing.js +3 -3
  47. package/lib/utils/EventsReader.js +1 -1
  48. package/lib/utils/ExecutionQueue.js +1 -1
  49. package/lib/utils/KeyBasedExecutionQueues.js +2 -2
  50. package/lib/utils/ProfileLogFilesystemWriter.js +4 -4
  51. package/lib/utils/SingleEmitQueue.js +1 -1
  52. package/lib/utils/SplitEmitQueue.js +1 -1
  53. package/lib/utils/profileLog.js +1 -1
  54. package/lib/utils/validation.js +1 -1
  55. package/lib/utils/validators.js +7 -5
  56. package/lib/utils.js +5 -2
  57. package/package.json +5 -15
package/index.js CHANGED
@@ -1,30 +1,44 @@
1
- const App = require('./lib/App.js')
1
+ import App from './lib/App.js'
2
2
 
3
- module.exports = App
4
-
5
- module.exports.app = () => {
3
+ App.app = () => {
6
4
  if(!globalThis.liveChangeFrameworkApp) {
7
5
  globalThis.liveChangeFrameworkApp = new App()
8
6
  }
9
7
  return globalThis.liveChangeFrameworkApp
10
8
  }
11
9
 
12
- module.exports.utils = require('./lib/utils.js')
13
- module.exports.validation = require('./lib/utils/validation.js')
14
- module.exports.rangeProperties = module.exports.utils.rangeProperties
15
- module.exports.encodeIdentifier = module.exports.utils.encodeIdentifier
16
- module.exports.extractRange = module.exports.utils.extractRange
17
- module.exports.isomorphic = module.exports.utils.isomorphic
10
+ import * as utils from './lib/utils.js'
11
+ import * as validation from './lib/utils/validation.js'
12
+
13
+ App.utils = utils
14
+ App.validation = validation
15
+ App.rangeProperties = utils.rangeProperties
16
+ App.encodeIdentifier = utils.encodeIdentifier
17
+ App.extractRange = utils.extractRange
18
+ App.isomorphic = utils.isomorphic
18
19
 
20
+ export default App
19
21
 
20
- module.exports.ActionDefinition = require('./lib/definition/ActionDefinition.js')
21
- module.exports.EventDefinition = require('./lib/definition/EventDefinition.js')
22
- module.exports.ForeignIndexDefinition = require('./lib/definition/ForeignIndexDefinition.js')
23
- module.exports.ForeignModelDefinition = require('./lib/definition/ForeignModelDefinition.js')
24
- module.exports.IndexDefinition = require('./lib/definition/IndexDefinition.js')
25
- module.exports.ModelDefinition = require('./lib/definition/ModelDefinition.js')
26
- module.exports.PropertyDefinition = require('./lib/definition/PropertyDefinition.js')
27
- module.exports.ServiceDefinition = require('./lib/definition/ServiceDefinition.js')
28
- module.exports.TriggerDefinition = require('./lib/definition/TriggerDefinition.js')
29
- module.exports.ViewDefinition = require('./lib/definition/ViewDefinition.js')
22
+ import ActionDefinition from './lib/definition/ActionDefinition.js'
23
+ import EventDefinition from './lib/definition/EventDefinition.js'
24
+ import ForeignIndexDefinition from './lib/definition/ForeignIndexDefinition.js'
25
+ import ForeignModelDefinition from './lib/definition/ForeignModelDefinition.js'
26
+ import IndexDefinition from './lib/definition/IndexDefinition.js'
27
+ import ModelDefinition from './lib/definition/ModelDefinition.js'
28
+ import PropertyDefinition from './lib/definition/PropertyDefinition.js'
29
+ import ServiceDefinition from './lib/definition/ServiceDefinition.js'
30
+ import TriggerDefinition from './lib/definition/TriggerDefinition.js'
31
+ import ViewDefinition from './lib/definition/ViewDefinition.js'
30
32
 
33
+ export {
34
+ ActionDefinition,
35
+ EventDefinition,
36
+ ForeignIndexDefinition,
37
+ ForeignModelDefinition,
38
+ IndexDefinition,
39
+ ModelDefinition,
40
+ PropertyDefinition,
41
+ ServiceDefinition,
42
+ TriggerDefinition,
43
+ ViewDefinition
44
+ }
package/lib/App.js CHANGED
@@ -1,42 +1,42 @@
1
- const { uidGenerator, randomString } = require('@live-change/uid')
1
+ import { uidGenerator, randomString } from '@live-change/uid'
2
2
 
3
- const ReactiveDao = require("@live-change/dao")
3
+ import ReactiveDao from "@live-change/dao"
4
4
 
5
- const ServiceDefinition = require("./definition/ServiceDefinition.js")
5
+ import ServiceDefinition from "./definition/ServiceDefinition.js"
6
6
 
7
- const Service = require("./runtime/Service.js")
7
+ import Service from "./runtime/Service.js"
8
8
 
9
- const profileLog = require("./utils/profileLog.js")
9
+ import profileLog from "./utils/profileLog.js"
10
10
 
11
- const Dao = require("./runtime/Dao.js")
12
- const SessionDao = require("./runtime/SessionDao.js")
13
- const LiveDao = require("./runtime/LiveDao.js")
14
- const ApiServer = require("./runtime/ApiServer.js")
11
+ import Dao from "./runtime/Dao.js"
12
+ import SessionDao from "./runtime/SessionDao.js"
13
+ import LiveDao from "./runtime/LiveDao.js"
14
+ import ApiServer from "./runtime/ApiServer.js"
15
15
 
16
- const reverseRelationProcessor = require("./processors/reverseRelation.js")
17
- const indexListProcessor = require("./processors/indexList.js")
18
- const crudGenerator = require("./processors/crudGenerator.js")
19
- const draftGenerator = require("./processors/draftGenerator.js")
20
- const daoPathView = require("./processors/daoPathView.js")
21
- const fetchView = require("./processors/fetchView.js")
22
- const accessControl = require("./processors/accessControl.js")
23
- const autoValidation = require("./processors/autoValidation.js")
24
- const indexCode = require("./processors/indexCode.js")
16
+ import reverseRelationProcessor from "./processors/reverseRelation.js"
17
+ import indexListProcessor from "./processors/indexList.js"
18
+ import crudGenerator from "./processors/crudGenerator.js"
19
+ import draftGenerator from "./processors/draftGenerator.js"
20
+ import daoPathView from "./processors/daoPathView.js"
21
+ import fetchView from "./processors/fetchView.js"
22
+ import accessControl from "./processors/accessControl.js"
23
+ import autoValidation from "./processors/autoValidation.js"
24
+ import indexCode from "./processors/indexCode.js"
25
25
 
26
- const databaseUpdater = require("./updaters/database.js")
26
+ import databaseUpdater from "./updaters/database.js"
27
27
 
28
- const accessControlFilter = require("./clientSideFilters/accessFilter.js")
29
- const clientSideFilter = require("./clientSideFilters/clientSideFilter.js")
28
+ import accessControlFilter from "./clientSideFilters/accessFilter.js"
29
+ import clientSideFilter from "./clientSideFilters/clientSideFilter.js"
30
30
 
31
- const commandExecutor = require("./processes/commandExecutor.js")
32
- const triggerExecutor = require("./processes/triggerExecutor.js")
33
- const eventListener = require('./processes/eventListener.js')
31
+ import commandExecutor from "./processes/commandExecutor.js"
32
+ import triggerExecutor from "./processes/triggerExecutor.js"
33
+ import eventListener from './processes/eventListener.js'
34
34
 
35
- const utils = require('./utils.js')
36
- const SplitEmitQueue = require("./utils/SplitEmitQueue.js");
37
- const SingleEmitQueue = require("./utils/SingleEmitQueue.js");
35
+ import SplitEmitQueue from "./utils/SplitEmitQueue.js"
36
+ import SingleEmitQueue from "./utils/SingleEmitQueue.js"
38
37
 
39
- const debug = require('debug')('framework')
38
+ import Debug from 'debug'
39
+ const debug = Debug('framework')
40
40
 
41
41
  class App {
42
42
 
@@ -89,8 +89,9 @@ class App {
89
89
  }
90
90
 
91
91
  createServiceDefinition( definition ) {
92
- const config = this.config && this.config.services && this.config.services.find
92
+ const sourceConfig = this.config && this.config.services && this.config.services.find
93
93
  && this.config.services.find(c => c.name == definition.name)
94
+ const config = { ...sourceConfig, module: null }
94
95
  return new ServiceDefinition({ ...definition, config })
95
96
  }
96
97
 
@@ -542,5 +543,4 @@ class App {
542
543
 
543
544
  }
544
545
 
545
-
546
- module.exports = App
546
+ export default App
@@ -1,6 +1,6 @@
1
- const getAccessMethod = require("../processors/accessMethod.js")
1
+ import getAccessMethod from "../processors/accessMethod.js"
2
2
 
3
- module.exports = async function(service, definition, app, client) {
3
+ export default async function(service, definition, app, client) {
4
4
 
5
5
  for(let actionName in definition.actions) {
6
6
  const action = service.definition.actions[actionName]
@@ -1,5 +1,5 @@
1
1
 
2
- module.exports = function(service, definition, app) {
2
+ export default function clientSideFilter(service, definition, app) {
3
3
  /* for(let actionName in service.actions) {
4
4
  const action = service.actions[actionName]
5
5
 
@@ -1,5 +1,4 @@
1
- const PropertyDefinition = require("./PropertyDefinition.js")
2
- const utils = require("../utils.js")
1
+ import PropertyDefinition from "./PropertyDefinition.js"
3
2
 
4
3
  class ActionDefinition {
5
4
 
@@ -37,4 +36,4 @@ class ActionDefinition {
37
36
 
38
37
  }
39
38
 
40
- module.exports = ActionDefinition
39
+ export default ActionDefinition
@@ -1,5 +1,4 @@
1
- const PropertyDefinition = require("./PropertyDefinition.js")
2
- const utils = require("../utils.js")
1
+ import PropertyDefinition from "./PropertyDefinition.js"
3
2
 
4
3
  class EventDefinition {
5
4
 
@@ -43,4 +42,4 @@ class EventDefinition {
43
42
  }
44
43
  }
45
44
 
46
- module.exports = EventDefinition
45
+ export default EventDefinition
@@ -1,4 +1,3 @@
1
- const utils = require("../utils.js")
2
1
 
3
2
  class ForeignIndexDefinition {
4
3
 
@@ -16,4 +15,4 @@ class ForeignIndexDefinition {
16
15
 
17
16
  }
18
17
 
19
- module.exports = ForeignIndexDefinition
18
+ export default ForeignIndexDefinition
@@ -1,5 +1,3 @@
1
- const utils = require("../utils.js")
2
-
3
1
  class ForeignModelDefinition {
4
2
 
5
3
  constructor(serviceName, modelName) {
@@ -20,4 +18,4 @@ class ForeignModelDefinition {
20
18
 
21
19
  }
22
20
 
23
- module.exports = ForeignModelDefinition
21
+ export default ForeignModelDefinition
@@ -1,5 +1,3 @@
1
- const PropertyDefinition = require("./PropertyDefinition.js")
2
- const utils = require("../utils.js")
3
1
 
4
2
  class IndexDefinition {
5
3
 
@@ -37,8 +35,6 @@ class IndexDefinition {
37
35
  return changes
38
36
  }
39
37
 
40
-
41
-
42
38
  }
43
39
 
44
- module.exports = IndexDefinition
40
+ export default IndexDefinition
@@ -1,5 +1,5 @@
1
- const PropertyDefinition = require("./PropertyDefinition.js")
2
- const utils = require("../utils.js")
1
+ import PropertyDefinition from "./PropertyDefinition.js"
2
+ import { crudChanges } from "../utils.js"
3
3
 
4
4
  class ModelDefinition {
5
5
 
@@ -55,9 +55,9 @@ class ModelDefinition {
55
55
  oldModel.indexes = oldModel.indexes || {}
56
56
  let changes = []
57
57
  const json = this.toJSON()
58
- changes.push(...utils.crudChanges(oldModel.properties || {}, json.properties || {},
58
+ changes.push(...crudChanges(oldModel.properties || {}, json.properties || {},
59
59
  "Property", "property", { model: this.name }))
60
- changes.push(...utils.crudChanges(oldModel.indexes || {}, json.indexes || {},
60
+ changes.push(...crudChanges(oldModel.indexes || {}, json.indexes || {},
61
61
  "Index", "index", { model: this.name, storage: this.storage }))
62
62
  if(oldModel.search && !this.search) changes.push({ operation: "searchDisabled", model: this.name })
63
63
  if(!oldModel.search && this.search) changes.push({ operation: "searchEnabled", model: this.name })
@@ -76,8 +76,6 @@ class ModelDefinition {
76
76
  return changes
77
77
  }
78
78
 
79
-
80
-
81
79
  }
82
80
 
83
- module.exports = ModelDefinition
81
+ export default ModelDefinition
@@ -1,4 +1,4 @@
1
- const utils = require("../utils.js")
1
+ import { typeName } from "../utils.js"
2
2
 
3
3
  class PropertyDefinition {
4
4
 
@@ -30,7 +30,7 @@ class PropertyDefinition {
30
30
  }
31
31
  let json = {
32
32
  ...this,
33
- type: utils.typeName(this.type),
33
+ type: typeName(this.type),
34
34
  properties
35
35
  }
36
36
  if(this.of) {
@@ -43,8 +43,8 @@ class PropertyDefinition {
43
43
  computeChanges( oldProperty, params, name) {
44
44
  let changes = []
45
45
  let typeChanged = false
46
- if(utils.typeName(this.type) != utils.typeName(oldProperty.type)) typeChanged = true
47
- if((this.of && utils.typeName(this.of.type)) != (oldProperty.of && utils.typeName(oldProperty.of.type)))
46
+ if(typeName(this.type) != typeName(oldProperty.type)) typeChanged = true
47
+ if((this.of && typeName(this.of.type)) != (oldProperty.of && typeName(oldProperty.of.type)))
48
48
  typeChanged = true
49
49
  if(typeChanged) {
50
50
  changes.push({
@@ -67,4 +67,4 @@ class PropertyDefinition {
67
67
 
68
68
  }
69
69
 
70
- module.exports = PropertyDefinition
70
+ export default PropertyDefinition
@@ -1,13 +1,13 @@
1
- const ModelDefinition = require("./ModelDefinition.js")
2
- const ForeignModelDefinition = require("./ForeignModelDefinition.js")
3
- const IndexDefinition = require("./IndexDefinition.js")
4
- const ForeignIndexDefinition = require("./ForeignIndexDefinition.js")
5
- const ActionDefinition = require("./ActionDefinition.js")
6
- const TriggerDefinition = require("./TriggerDefinition.js")
7
- const ViewDefinition = require("./ViewDefinition.js")
8
- const EventDefinition = require("./EventDefinition.js")
9
- const defaultValidators = require('../utils/validators.js')
10
- const utils = require("../utils.js")
1
+ import ModelDefinition from "./ModelDefinition.js"
2
+ import ForeignModelDefinition from "./ForeignModelDefinition.js"
3
+ import IndexDefinition from "./IndexDefinition.js"
4
+ import ForeignIndexDefinition from "./ForeignIndexDefinition.js"
5
+ import ActionDefinition from "./ActionDefinition.js"
6
+ import TriggerDefinition from "./TriggerDefinition.js"
7
+ import ViewDefinition from "./ViewDefinition.js"
8
+ import EventDefinition from "./EventDefinition.js"
9
+ import defaultValidators from '../utils/validators.js'
10
+ import { crudChanges } from "../utils.js"
11
11
 
12
12
  function createModelProxy(definition, model) {
13
13
  return new Proxy(model, {
@@ -86,7 +86,7 @@ class ServiceDefinition {
86
86
  this.authenticators = []
87
87
  this.beforeStartCallbacks = []
88
88
  this.endpoints = []
89
- this.validators = defaultValidators
89
+ this.validators = { ...defaultValidators }
90
90
  this.clientSideFilters = []
91
91
  for(let key in definition) this[key] = definition[key]
92
92
  }
@@ -209,11 +209,11 @@ class ServiceDefinition {
209
209
  computeChanges( oldModuleParam ) {
210
210
  let oldModule = JSON.parse(JSON.stringify(oldModuleParam))
211
211
  let changes = []
212
- changes.push(...utils.crudChanges(oldModule.models || {}, this.models || {},
212
+ changes.push(...crudChanges(oldModule.models || {}, this.models || {},
213
213
  "Model", "model", { }))
214
214
  return changes
215
215
  }
216
216
 
217
217
  }
218
218
 
219
- module.exports = ServiceDefinition
219
+ export default ServiceDefinition
@@ -1,4 +1,4 @@
1
- const PropertyDefinition = require("./PropertyDefinition.js")
1
+ import PropertyDefinition from "./PropertyDefinition.js"
2
2
 
3
3
  class TriggerDefinition {
4
4
 
@@ -36,4 +36,4 @@ class TriggerDefinition {
36
36
 
37
37
  }
38
38
 
39
- module.exports = TriggerDefinition
39
+ export default TriggerDefinition
@@ -1,4 +1,4 @@
1
- const PropertyDefinition = require("./PropertyDefinition.js")
1
+ import PropertyDefinition from "./PropertyDefinition.js"
2
2
 
3
3
  class ViewDefinition {
4
4
 
@@ -36,4 +36,4 @@ class ViewDefinition {
36
36
 
37
37
  }
38
38
 
39
- module.exports = ViewDefinition
39
+ export default ViewDefinition
@@ -1,7 +1,7 @@
1
- const KeyBasedExecutionQueues = require('../utils/KeyBasedExecutionQueues.js')
2
- const CommandQueue = require('../utils/CommandQueue.js')
3
- const SingleEmitQueue = require('../utils/SingleEmitQueue.js')
4
- const SplitEmitQueue = require('../utils/SplitEmitQueue.js')
1
+ import KeyBasedExecutionQueues from '../utils/KeyBasedExecutionQueues.js';
2
+ import CommandQueue from '../utils/CommandQueue.js';
3
+ import SingleEmitQueue from '../utils/SingleEmitQueue.js';
4
+ import SplitEmitQueue from '../utils/SplitEmitQueue.js';
5
5
 
6
6
  async function startCommandExecutor(service, config) {
7
7
  if(!config.runCommands) return
@@ -94,4 +94,4 @@ async function startCommandExecutor(service, config) {
94
94
  service.commandQueue.start()
95
95
  }
96
96
 
97
- module.exports = startCommandExecutor
97
+ export default startCommandExecutor
@@ -1,4 +1,4 @@
1
- const EventSourcing = require('../utils/EventSourcing.js')
1
+ import EventSourcing from '../utils/EventSourcing.js'
2
2
 
3
3
  async function startEventListener(service, config) {
4
4
  if(!config.handleEvents) return
@@ -36,4 +36,4 @@ async function startEventListener(service, config) {
36
36
  service.eventSourcing.start()
37
37
  }
38
38
 
39
- module.exports = startEventListener
39
+ export default startEventListener
@@ -1,7 +1,7 @@
1
- const KeyBasedExecutionQueues = require('../utils/KeyBasedExecutionQueues.js')
2
- const CommandQueue = require('../utils/CommandQueue.js')
3
- const SingleEmitQueue = require('../utils/SingleEmitQueue.js')
4
- const SplitEmitQueue = require('../utils/SplitEmitQueue.js')
1
+ import KeyBasedExecutionQueues from '../utils/KeyBasedExecutionQueues.js'
2
+ import CommandQueue from '../utils/CommandQueue.js'
3
+ import SingleEmitQueue from '../utils/SingleEmitQueue.js'
4
+ import SplitEmitQueue from '../utils/SplitEmitQueue.js'
5
5
 
6
6
  async function startTriggerExecutor(service, config) {
7
7
  if(!config.runCommands) return
@@ -34,4 +34,4 @@ async function startTriggerExecutor(service, config) {
34
34
  service.triggerQueue.start()
35
35
  }
36
36
 
37
- module.exports = startTriggerExecutor
37
+ export default startTriggerExecutor
@@ -1,6 +1,6 @@
1
- const getAccessMethod = require("./accessMethod.js")
1
+ import getAccessMethod from "./accessMethod.js"
2
2
 
3
- module.exports = function(module, app) {
3
+ export default function(module, app) {
4
4
  for(let actionName in module.actions) {
5
5
  const action = module.actions[actionName]
6
6
  if(!action.access) continue;
@@ -1,4 +1,4 @@
1
- function getAccessMethod(access) {
1
+ export default function getAccessMethod(access) {
2
2
  if(typeof access == 'function') {
3
3
  return access
4
4
  } else if(Array.isArray(access)) {
@@ -10,5 +10,3 @@ function getAccessMethod(access) {
10
10
  }
11
11
  } else throw new Error("unknown view access definition "+access)
12
12
  }
13
-
14
- module.exports = getAccessMethod
@@ -1,6 +1,6 @@
1
- const { getValidators, validate } = require('../utils/validation.js')
1
+ import { getValidators, validate } from '../utils/validation.js'
2
2
 
3
- module.exports = function(service, app) {
3
+ export default function(service, app) {
4
4
  for(let actionName in service.actions) {
5
5
  const action = service.actions[actionName]
6
6
  if(action.skipValidation) continue
@@ -1,4 +1,4 @@
1
- const utils = require("../utils.js")
1
+ import * as utils from "../utils.js"
2
2
 
3
3
  function ignoreValidation(prop) {
4
4
  delete prop.validation
@@ -12,7 +12,7 @@ function ignoreValidation(prop) {
12
12
  }
13
13
  }
14
14
 
15
- module.exports = function(service, app) {
15
+ export default function(service, app) {
16
16
  if(!service) throw new Error("no service")
17
17
  if(!app) throw new Error("no service")
18
18
  for(let modelName in service.models) {
@@ -1,6 +1,6 @@
1
- const ReactiveDao = require("@live-change/dao")
1
+ import ReactiveDao from "@live-change/dao"
2
2
 
3
- module.exports = function(service, app) {
3
+ export default function(service, app) {
4
4
  for(let viewName in service.views) {
5
5
  const view = service.views[viewName]
6
6
  if(view.daoPath) {
@@ -1,4 +1,4 @@
1
- const utils = require("../utils.js")
1
+ import * as utils from "../utils.js"
2
2
 
3
3
  function propertyWithoutValidation(property) {
4
4
  let prop = { ...property }
@@ -20,7 +20,7 @@ function propertiesWithoutValidation(properties, validateFields) {
20
20
  return propertiesWV
21
21
  }
22
22
 
23
- module.exports = function(service, app) {
23
+ export default function(service, app) {
24
24
  if(!service) throw new Error("no service")
25
25
  if(!app) throw new Error("no service")
26
26
  for(let actionName in service.actions) {
@@ -1,6 +1,6 @@
1
- const ReactiveDao = require("@live-change/dao")
1
+ import ReactiveDao from "@live-change/dao"
2
2
 
3
- module.exports = function(service, app) {
3
+ export default function(service, app) {
4
4
  for(let viewName in service.views) {
5
5
  const view = service.views[viewName]
6
6
  if(view.fetch) {
@@ -1,5 +1,4 @@
1
-
2
- module.exports = function(module, app) {
1
+ export default function(module, app) {
3
2
  for(let modelName in module.models) {
4
3
  const model = module.models[modelName]
5
4
  for(let indexName in model.indexes) {
@@ -1,6 +1,6 @@
1
- const utils = require("../utils.js")
1
+ import * as utils from "../utils.js"
2
2
 
3
- module.exports = function(module, app) {
3
+ export default function(module, app) {
4
4
  for(let modelName in module.models) {
5
5
  const model = module.models[modelName]
6
6
  for(let propertyName in model.properties) {
@@ -1,6 +1,6 @@
1
- const utils = require("../utils.js")
1
+ import * as utils from "../utils.js"
2
2
 
3
- module.exports = function(module, app) {
3
+ export default function(module, app) {
4
4
  for(let modelName in module.models) {
5
5
  const model = module.models[modelName]
6
6
  for(let propertyName in model.properties) {
@@ -1,4 +1,4 @@
1
- const { prepareParameters, processReturn, preFilterParameters } = require("./params.js")
1
+ import { prepareParameters, processReturn, preFilterParameters } from "./params.js"
2
2
 
3
3
  class Action {
4
4
 
@@ -48,4 +48,4 @@ class Action {
48
48
  }
49
49
  }
50
50
 
51
- module.exports = Action
51
+ export default Action
@@ -1,8 +1,8 @@
1
- const LcDao = require("@live-change/dao")
2
- const Dao = require("./Dao.js")
3
- const cookie = require('cookie')
1
+ import LcDao from "@live-change/dao"
2
+ import Dao from "./Dao.js"
3
+ import cookie from 'cookie'
4
4
 
5
- const { getIp } = require("./utils.js")
5
+ import { getIp } from "./utils.js"
6
6
 
7
7
  class ApiServer {
8
8
  constructor(config, DaoConstructor = Dao) {
@@ -55,4 +55,4 @@ class ApiServer {
55
55
  }
56
56
  }
57
57
 
58
- module.exports = ApiServer
58
+ export default ApiServer
@@ -1,6 +1,6 @@
1
- const ReactiveDao = require("@live-change/dao")
1
+ import ReactiveDao from "@live-change/dao"
2
2
 
3
- const profileLog = require("../utils/profileLog.js")
3
+ import profileLog from "../utils/profileLog.js"
4
4
 
5
5
  function promiseMap(promise, fn) {
6
6
  if(promise.then) return promise.then(fn)
@@ -181,4 +181,4 @@ class Dao extends ReactiveDao {
181
181
  }
182
182
  }
183
183
 
184
- module.exports = Dao
184
+ export default Dao
@@ -1,4 +1,4 @@
1
- const { prepareParameters, processReturn } = require("./params.js")
1
+ import { prepareParameters, processReturn } from "./params.js"
2
2
 
3
3
  class EventHandler {
4
4
 
@@ -31,4 +31,4 @@ class EventHandler {
31
31
  }
32
32
  }
33
33
 
34
- module.exports = EventHandler
34
+ export default EventHandler
@@ -1,4 +1,4 @@
1
- const ReaderModel = require("./ReaderModel.js")
1
+ import ReaderModel from "./ReaderModel.js"
2
2
 
3
3
  class ForeignModel extends ReaderModel {
4
4
 
@@ -9,4 +9,4 @@ class ForeignModel extends ReaderModel {
9
9
 
10
10
  }
11
11
 
12
- module.exports = ForeignModel
12
+ export default ForeignModel
@@ -1,5 +1,5 @@
1
- const ReactiveDao = require("@live-change/dao")
2
- const utils = require("../utils.js");
1
+ import ReactiveDao from "@live-change/dao"
2
+ import { prefixRange } from "../utils.js"
3
3
 
4
4
  class Index {
5
5
 
@@ -19,7 +19,7 @@ class Index {
19
19
  const values = Array.isArray(range) ? range : [range]
20
20
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
21
21
  if(pathRange) {
22
- return this.rangePath(utils.prefixRange(pathRange, prefix, prefix))
22
+ return this.rangePath(prefixRange(pathRange, prefix, prefix))
23
23
  }
24
24
  return this.rangePath({ gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
25
25
  }
@@ -45,4 +45,4 @@ class Index {
45
45
 
46
46
  }
47
47
 
48
- module.exports = Index
48
+ export default Index
@@ -1,7 +1,7 @@
1
- const LcDao = require("@live-change/dao")
2
- const Dao = require("./Dao.js")
1
+ import LcDao from "@live-change/dao"
2
+ import Dao from "./Dao.js"
3
3
 
4
- const { waitForSignal } = require('./utils.js')
4
+ import { waitForSignal } from './utils.js'
5
5
 
6
6
  class LiveDao extends LcDao.DaoProxy {
7
7
  constructor(config, credentials) {
@@ -94,4 +94,4 @@ class LiveDao extends LcDao.DaoProxy {
94
94
  }
95
95
  }
96
96
 
97
- module.exports = LiveDao
97
+ export default LiveDao
@@ -1,5 +1,5 @@
1
- const ReaderModel = require("./ReaderModel.js")
2
- const utils = require("../utils.js");
1
+ import ReaderModel from "./ReaderModel.js"
2
+ import { prefixRange }from "../utils.js"
3
3
 
4
4
  class Model extends ReaderModel {
5
5
 
@@ -44,7 +44,7 @@ class Model extends ReaderModel {
44
44
  const values = Array.isArray(range) ? range : [range]
45
45
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
46
46
  if(pathRange) {
47
- return this.rangePath(utils.prefixRange(pathRange, prefix, prefix))
47
+ return this.rangePath(prefixRange(pathRange, prefix, prefix))
48
48
  }
49
49
  return this.rangePath({ gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
50
50
  }
@@ -63,7 +63,7 @@ class Model extends ReaderModel {
63
63
  const values = Array.isArray(range) ? range : [range]
64
64
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
65
65
  if(pathRange) {
66
- return this.indexRangeDelete(index, utils.prefixRange(pathRange, prefix, prefix))
66
+ return this.indexRangeDelete(index, prefixRange(pathRange, prefix, prefix))
67
67
  }
68
68
  return this.indexRangeDelete(index,{ gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
69
69
  }
@@ -81,7 +81,7 @@ class Model extends ReaderModel {
81
81
  const values = Array.isArray(range) ? range : [range]
82
82
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
83
83
  if(pathRange) {
84
- return this.indexRangeUpdate(index, update, utils.prefixRange(pathRange, prefix, prefix))
84
+ return this.indexRangeUpdate(index, update, prefixRange(pathRange, prefix, prefix))
85
85
  }
86
86
  return this.indexRangeUpdate(index, update,{ gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
87
87
  }
@@ -95,8 +95,6 @@ class Model extends ReaderModel {
95
95
  })`, { indexName: this.tableName+'_'+index, tableName: this.tableName, range, operations })
96
96
  }
97
97
 
98
-
99
-
100
98
  }
101
99
 
102
- module.exports = Model
100
+ export default Model
@@ -1,5 +1,5 @@
1
- const ReactiveDao = require("@live-change/dao")
2
- const utils = require('../utils.js')
1
+ import LcDao from "@live-change/dao"
2
+ import { prefixRange, fieldListToFieldsObject } from "../utils.js"
3
3
 
4
4
  class ReaderModel {
5
5
 
@@ -16,7 +16,7 @@ class ReaderModel {
16
16
 
17
17
  limitedPath(id, fields) { // takes object or list of fields
18
18
  if(Array.isArray(fields)) {
19
- fields = utils.fieldListToFieldsObject(fields)
19
+ fields = fieldListToFieldsObject(fields)
20
20
  }
21
21
  fields.id = true // id is required
22
22
  return ['database', 'queryObject', this.service.databaseName, `(${
@@ -44,7 +44,7 @@ class ReaderModel {
44
44
  const values = Array.isArray(range) ? range : [range]
45
45
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
46
46
  if(pathRange) {
47
- return this.rangePath(utils.prefixRange(pathRange, prefix, prefix))
47
+ return this.rangePath(prefixRange(pathRange, prefix, prefix))
48
48
  }
49
49
  return this.rangePath({ gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
50
50
  }
@@ -57,7 +57,7 @@ class ReaderModel {
57
57
  const values = Array.isArray(range) ? range : [range]
58
58
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
59
59
  if(pathRange) {
60
- return this.indexRangePath(index, utils.prefixRange(pathRange, prefix, prefix))
60
+ return this.indexRangePath(index, prefixRange(pathRange, prefix, prefix))
61
61
  }
62
62
  return this.indexRangePath(index, { gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
63
63
  }
@@ -115,7 +115,7 @@ class ReaderModel {
115
115
  const values = Array.isArray(range) ? range : [range]
116
116
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
117
117
  if(pathRange) {
118
- return this.sortedIndexRangePath(index, utils.prefixRange(pathRange, prefix, prefix))
118
+ return this.sortedIndexRangePath(index, prefixRange(pathRange, prefix, prefix))
119
119
  }
120
120
  return this.sortedIndexRangePath(index, { gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
121
121
  }
@@ -178,7 +178,7 @@ class ReaderModel {
178
178
  const values = Array.isArray(range) ? range : [range]
179
179
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
180
180
  if(pathRange) {
181
- return this.indexObjectPath(index, utils.prefixRange(pathRange, prefix, prefix))
181
+ return this.indexObjectPath(index, prefixRange(pathRange, prefix, prefix))
182
182
  }
183
183
  return this.indexObjectPath(index,{ gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
184
184
  }
@@ -216,7 +216,7 @@ class ReaderModel {
216
216
  const values = Array.isArray(range) ? range : [range]
217
217
  const prefix = values.map(value => value === undefined ? '' : JSON.stringify(value)).join(':')
218
218
  if(pathRange) {
219
- return this.countPath(utils.prefixRange(pathRange, prefix, prefix))
219
+ return this.countPath(prefixRange(pathRange, prefix, prefix))
220
220
  }
221
221
  return this.countPath({ gte: prefix+':', lte: prefix+'_\xFF\xFF\xFF\xFF' })
222
222
  }
@@ -225,22 +225,22 @@ class ReaderModel {
225
225
  }
226
226
 
227
227
  observable(id) {
228
- return this.service.dao.observable(this.path(id), ReactiveDao.ObservableValue)
228
+ return this.service.dao.observable(this.path(id), LcDao.ObservableValue)
229
229
  }
230
230
  async get(id) {
231
- return this.service.dao.get(this.path(id), ReactiveDao.ObservableValue)
231
+ return this.service.dao.get(this.path(id), LcDao.ObservableValue)
232
232
  }
233
233
  rangeObservable(range) {
234
- return this.service.dao.observable(this.rangePath(range), ReactiveDao.ObservableList)
234
+ return this.service.dao.observable(this.rangePath(range), LcDao.ObservableList)
235
235
  }
236
236
  async rangeGet(range) {
237
- return this.service.dao.get(this.rangePath(range), ReactiveDao.ObservableList)
237
+ return this.service.dao.get(this.rangePath(range), LcDao.ObservableList)
238
238
  }
239
239
  indexRangeObservable(index, range, pathRange = null) {
240
- return this.service.dao.observable(this.indexRangePath(index, range, pathRange), ReactiveDao.ObservableList)
240
+ return this.service.dao.observable(this.indexRangePath(index, range, pathRange), LcDao.ObservableList)
241
241
  }
242
242
  async indexRangeGet(index, range, pathRange = null) {
243
- return this.service.dao.get(this.indexRangePath(index, range, pathRange), ReactiveDao.ObservableList)
243
+ return this.service.dao.get(this.indexRangePath(index, range, pathRange), LcDao.ObservableList)
244
244
  }
245
245
  indexObjectObservable(index, range, pathRange = null) {
246
246
  return this.service.dao.observable(this.indexObjectPath(index, range, pathRange))
@@ -249,16 +249,16 @@ class ReaderModel {
249
249
  return this.service.dao.get(this.indexObjectPath(index, range, pathRange))
250
250
  }
251
251
  sortedIndexRangeObservable(index, range, pathRange = null) {
252
- return this.service.dao.observable(this.sortedIndexRangePath(index, range, pathRange), ReactiveDao.ObservableList)
252
+ return this.service.dao.observable(this.sortedIndexRangePath(index, range, pathRange), LcDao.ObservableList)
253
253
  }
254
254
  async sortedIndexRangeGet(index, range, pathRange = null) {
255
- return this.service.dao.get(this.sortedIndexRangePath(index, range, pathRange), ReactiveDao.ObservableList)
255
+ return this.service.dao.get(this.sortedIndexRangePath(index, range, pathRange), LcDao.ObservableList)
256
256
  }
257
257
  countObservable(range) {
258
- return this.service.dao.observable(this.countPath(range), ReactiveDao.ObservableList)
258
+ return this.service.dao.observable(this.countPath(range), LcDao.ObservableList)
259
259
  }
260
260
  async countGet(range) {
261
- return this.service.dao.get(this.countPath(range), ReactiveDao.ObservableList)
261
+ return this.service.dao.get(this.countPath(range), LcDao.ObservableList)
262
262
  }
263
263
 
264
264
  condition(id, condition = x => !!x, timeout = 10000) {
@@ -286,4 +286,4 @@ class ReaderModel {
286
286
 
287
287
  }
288
288
 
289
- module.exports = ReaderModel
289
+ export default ReaderModel
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  const SEARCH_INDEX_NOTSTARTED = 0
4
2
  const SEARCH_INDEX_CREATING = 1
5
3
  const SEARCH_INDEX_UPDATING = 2
@@ -313,4 +311,4 @@ class SearchIndexer {
313
311
 
314
312
  }
315
313
 
316
- module.exports = SearchIndexer
314
+ export default SearchIndexer
@@ -1,11 +1,11 @@
1
- const Model = require("./Model.js")
2
- const ForeignModel = require("./ForeignModel.js")
3
- const Index = require("./Index.js")
4
- const View = require("./View.js")
5
- const Action = require("./Action.js")
6
- const EventHandler = require("./EventHandler.js")
7
- const TriggerHandler = require("./TriggerHandler.js")
8
- const ExecutionQueue = require("../utils/ExecutionQueue.js")
1
+ import Model from "./Model.js"
2
+ import ForeignModel from "./ForeignModel.js"
3
+ import Index from "./Index.js"
4
+ import View from "./View.js"
5
+ import Action from "./Action.js"
6
+ import EventHandler from "./EventHandler.js"
7
+ import TriggerHandler from "./TriggerHandler.js"
8
+ import ExecutionQueue from "../utils/ExecutionQueue.js"
9
9
 
10
10
  class Service {
11
11
 
@@ -99,4 +99,4 @@ class Service {
99
99
  }
100
100
 
101
101
 
102
- module.exports = Service
102
+ export default Service
@@ -1,7 +1,7 @@
1
- const LcDao = require("@live-change/dao")
2
- const Dao = require("./Dao.js")
1
+ import LcDao from "@live-change/dao"
2
+ import Dao from "./Dao.js"
3
3
 
4
- const { waitForSignal } = require('./utils.js')
4
+ import { waitForSignal } from './utils.js'
5
5
 
6
6
  class SessionDao extends LcDao.DaoProxy {
7
7
  constructor(config, credentials) {
@@ -90,4 +90,4 @@ class SessionDao extends LcDao.DaoProxy {
90
90
  }
91
91
  }
92
92
 
93
- module.exports = SessionDao
93
+ export default SessionDao
@@ -1,6 +1,6 @@
1
- const { prepareParameters, processReturn } = require("./params.js")
2
- const SplitEmitQueue = require("../utils/SplitEmitQueue.js");
3
- const SingleEmitQueue = require("../utils/SingleEmitQueue.js");
1
+ import { prepareParameters, processReturn } from "./params.js"
2
+ import SplitEmitQueue from "../utils/SplitEmitQueue.js"
3
+ import SingleEmitQueue from "../utils/SingleEmitQueue.js"
4
4
 
5
5
  class TriggerHandler {
6
6
 
@@ -108,4 +108,4 @@ class TriggerHandler {
108
108
 
109
109
  }
110
110
 
111
- module.exports = TriggerHandler
111
+ export default TriggerHandler
@@ -1,6 +1,6 @@
1
- const ReactiveDao = require('@live-change/dao')
1
+ import LcDao from '@live-change/dao'
2
2
 
3
- const { prepareParameters, processReturn } = require("./params.js")
3
+ import { prepareParameters, processReturn } from "./params.js"
4
4
 
5
5
  class View {
6
6
  constructor(definition, service) {
@@ -15,7 +15,7 @@ class View {
15
15
  }
16
16
  const preparedParameters = await prepareParameters(parameters, this.definition.properties, this.service)
17
17
  const observable = this.definition.observable(preparedParameters, context)
18
- if(observable === null) return new ReactiveDao.ObservableValue(null)
18
+ if(observable === null) return new LcDao.ObservableValue(null)
19
19
  return observable
20
20
  }
21
21
 
@@ -29,4 +29,4 @@ class View {
29
29
  }
30
30
  }
31
31
 
32
- module.exports = View
32
+ export default View
@@ -1,6 +1,5 @@
1
- const Model = require('./Model.js')
2
-
3
- const ModelDefinition = require('../definition/ModelDefinition')
1
+ import Model from './Model.js'
2
+ import ModelDefinition from '../definition/ModelDefinition.js'
4
3
 
5
4
  function getModelName(t) {
6
5
  let modelName = null
@@ -96,7 +95,7 @@ async function processReturn(data, definition, service) {
96
95
  return data
97
96
  }
98
97
 
99
- module.exports = {
98
+ export {
100
99
  processReturn,
101
100
  prepareParameters,
102
101
  preFilterParameters
@@ -1,4 +1,4 @@
1
- function getIp(connection) {
1
+ export function getIp(connection) {
2
2
  let ip =
3
3
  connection.headers['x-real-ip'] ||
4
4
  connection.headers['x-forwarded-for'] ||
@@ -9,7 +9,7 @@ function getIp(connection) {
9
9
  return ip
10
10
  }
11
11
 
12
- function waitForSignal(observable, timeout = 1000, filter = () => true) {
12
+ export function waitForSignal(observable, timeout = 1000, filter = () => true) {
13
13
  let observer
14
14
  let done = false
15
15
  return new Promise((resolve, reject) => {
@@ -32,7 +32,3 @@ function waitForSignal(observable, timeout = 1000, filter = () => true) {
32
32
  observable.unobserve(observer)
33
33
  })
34
34
  }
35
-
36
-
37
- module.exports.getIp = getIp
38
- module.exports.waitForSignal = waitForSignal
@@ -1,5 +1,6 @@
1
- const utils = require("../utils.js")
2
- const debug = require('debug')('framework:updaters:db')
1
+ import * as utils from "../utils.js"
2
+ import Debug from 'debug'
3
+ const debug = Debug('framework:updaters:db')
3
4
 
4
5
  async function update(changes, service, app, force) {
5
6
 
@@ -278,5 +279,5 @@ async function update(changes, service, app, force) {
278
279
  }
279
280
  }
280
281
 
281
- module.exports = update
282
+ export default update
282
283
 
@@ -1,4 +1,4 @@
1
- const ReactiveDao = require('@live-change/dao')
1
+ import ReactiveDao from '@live-change/dao'
2
2
 
3
3
  class CommandQueue {
4
4
  constructor(connection, database, tableName, serviceName, config) {
@@ -165,4 +165,4 @@ class CommandQueue {
165
165
  }
166
166
  }
167
167
 
168
- module.exports = CommandQueue
168
+ export default CommandQueue
@@ -1,5 +1,5 @@
1
- const EventsReader = require('./EventsReader.js')
2
- const ReactiveDao = require('@live-change/dao')
1
+ import EventsReader from './EventsReader.js'
2
+ import ReactiveDao from '@live-change/dao'
3
3
 
4
4
  function sleep(ms) {
5
5
  return new Promise((resolve, reject) => setTimeout(resolve, ms))
@@ -141,4 +141,4 @@ class EventSourcing {
141
141
  }
142
142
  }
143
143
 
144
- module.exports = EventSourcing
144
+ export default EventSourcing
@@ -90,4 +90,4 @@ class EventsReader {
90
90
 
91
91
  }
92
92
 
93
- module.exports = EventsReader
93
+ export default EventsReader
@@ -45,4 +45,4 @@ class ExecutionQueue {
45
45
 
46
46
  }
47
47
 
48
- module.exports = ExecutionQueue
48
+ export default ExecutionQueue
@@ -1,4 +1,4 @@
1
- const ExecutionQueue = require('./ExecutionQueue.js')
1
+ import ExecutionQueue from './ExecutionQueue.js'
2
2
 
3
3
  class KeyBasedExecutionQueues {
4
4
  constructor(keyFunction) {
@@ -22,4 +22,4 @@ class KeyBasedExecutionQueues {
22
22
  }
23
23
  }
24
24
 
25
- module.exports = KeyBasedExecutionQueues
25
+ export default KeyBasedExecutionQueues
@@ -1,6 +1,6 @@
1
- const fs = require('fs')
2
- const os = require('os')
3
- const { once } = require('events')
1
+ import fs from 'fs'
2
+ import os from 'os'
3
+ import { once } from 'events'
4
4
 
5
5
  class ProfileLogFilesystemWriter {
6
6
  constructor(path) {
@@ -37,4 +37,4 @@ class ProfileLogFilesystemWriter {
37
37
  }
38
38
  }
39
39
 
40
- module.exports = ProfileLogFilesystemWriter
40
+ export default ProfileLogFilesystemWriter
@@ -41,4 +41,4 @@ class SingleEmitQueue {
41
41
  }
42
42
  }
43
43
 
44
- module.exports = SingleEmitQueue
44
+ export default SingleEmitQueue
@@ -64,4 +64,4 @@ class SplitEmitQueue {
64
64
  }
65
65
  }
66
66
 
67
- module.exports = SplitEmitQueue
67
+ export default SplitEmitQueue
@@ -74,4 +74,4 @@ function getParamNames(func) {
74
74
  const profileLog = new ProfileLog()
75
75
  profileLog.ProfileLog = ProfileLog
76
76
 
77
- module.exports = profileLog
77
+ export default profileLog
@@ -52,4 +52,4 @@ async function validate(props, validators, context) {
52
52
  if(Object.keys(propErrors).length > 0) throw { properties: propErrors }
53
53
  }
54
54
 
55
- module.exports = { getValidator, getValidators, validate }
55
+ export { getValidator, getValidators, validate }
@@ -1,3 +1,5 @@
1
+ import {mergeDeep} from "../utils.js"
2
+
1
3
  function nonEmpty(value) {
2
4
  if(!value) return 'empty'
3
5
  if(typeof value == 'string') {
@@ -21,14 +23,14 @@ function getField(context, fieldName) {
21
23
  } else {
22
24
  path = propPath.concat(fieldName.split('.'))
23
25
  }
24
- let p = context.props
26
+ let p = mergeDeep(context.props, context.parameters)
25
27
  for(let part of path) p = p[part]
26
28
  return p
27
29
  }
28
30
 
29
31
  nonEmpty.isRequired = () => true
30
32
 
31
- let validators = {
33
+ const validators = {
32
34
  nonEmpty: (settings) => nonEmpty,
33
35
 
34
36
  minLength: ({ length }) => (value) => value.length < length ? 'tooShort' : undefined,
@@ -102,9 +104,9 @@ let validators = {
102
104
  ifNotOneOf: ({ prop, what, then }, { getValidator }) => {
103
105
  let validators = then.map(getValidator)
104
106
  const validator = (value, context) => {
105
- console.error("VIF NOT ONE OF", getField(context, prop), what, what.includes(getField(context, prop)))
107
+ //console.error("VIF NOT ONE OF", getField(context, prop), what, what.includes(getField(context, prop)))
106
108
  if(!what.includes(getField(context, prop))) {
107
- console.log("V", validators)
109
+ //console.log("V", validators)
108
110
  for(let v of validators) {
109
111
  const err = v(value, context)
110
112
  if(err) return err
@@ -174,4 +176,4 @@ let validators = {
174
176
  }
175
177
  }
176
178
 
177
- module.exports = validators
179
+ export default validators
package/lib/utils.js CHANGED
@@ -80,7 +80,10 @@ function crudChanges(oldElements, newElements, elementName, newParamName, params
80
80
  } else {
81
81
  if(newElement.computeChanges) {
82
82
  changes.push(...newElement.computeChanges(oldElement, params, newElementName))
83
- } else if(JSON.stringify(oldElement) != JSON.stringify(newElement)) {
83
+ } else if(
84
+ JSON.stringify({ ...oldElement, created: undefined })
85
+ != JSON.stringify({ ...newElement, created: undefined })
86
+ ) {
84
87
  let change = {
85
88
  operation: "delete"+elementName,
86
89
  ...params,
@@ -280,7 +283,7 @@ function isomorphic( v ) {
280
283
  }
281
284
  }
282
285
 
283
- module.exports = {
286
+ export {
284
287
  typeName, toJSON, setDifference, mapDifference, crudChanges,
285
288
  getProperty, setProperty, getField, setField, isObject, mergeDeep, generateDefault,
286
289
  prefixRange, rangeProperties, fieldListToFieldsObject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/framework",
3
- "version": "0.7.39",
3
+ "version": "0.8.1",
4
4
  "description": "Live Change Framework - ultimate solution for real time mobile/web apps",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,25 +15,15 @@
15
15
  "name": "Michał Łaszczewski",
16
16
  "url": "https://www.viamage.com/"
17
17
  },
18
+ "type": "module",
18
19
  "license": "MIT",
19
20
  "bugs": {
20
21
  "url": "https://github.com/live-change/live-change-framework/issues"
21
22
  },
22
23
  "homepage": "https://github.com/live-change/live-change-framework",
23
24
  "devDependencies": {
24
- "@live-change/dao": "0.5.22",
25
- "@live-change/dao-websocket": "0.5.22",
26
- "@live-change/db": "0.6.23",
27
- "@live-change/db-store-level": "0.6.23",
28
- "@live-change/db-store-lmdb": "0.6.23",
29
- "@live-change/sockjs": "0.4.1",
30
- "@live-change/uid": "^0.7.39",
31
- "cookie": "^0.4.1",
32
- "express": "^4.18.2",
33
- "os-service": "^2.2.0",
34
- "rimraf": "^3.0.2",
35
- "tape": "^5.3.2",
36
- "websocket": "^1.0.34"
25
+ "@live-change/dao": "0.6.0",
26
+ "@live-change/uid": "^0.8.1"
37
27
  },
38
- "gitHead": "9e9cd47f2fb1c3c82b20fdddbc5505c99e1e1c68"
28
+ "gitHead": "d26056b63edb7fecb98c6b9ee14eba859360f900"
39
29
  }