@live-change/framework 0.7.15 → 0.7.17

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.
@@ -12,13 +12,13 @@ class ApiServer {
12
12
  this.reactiveServer = new LcDao.ReactiveServer(
13
13
  (credentials, connection) => {
14
14
  const ip = getIp(connection)
15
- if(this.config.fastAuth) {
15
+ if(!credentials && this.config.fastAuth) {
16
16
  if(typeof this.config.fastAuth == 'function') {
17
17
  credentials = this.config.fastAuth(connection)
18
18
  } else {
19
19
  const cookies = cookie.parse(connection.headers.cookie || '')
20
20
  const sessionKey = cookies.sessionKey
21
- if(!sessionKey) throw new Error('session key undefined')
21
+ if(!sessionKey) return null // noFastAuth
22
22
  credentials = { sessionKey }
23
23
  }
24
24
  }
@@ -44,7 +44,7 @@ class ApiServer {
44
44
  if(authenticator.prepareCredentials) {
45
45
  await authenticator.prepareCredentials(credentials, this.config)
46
46
  }
47
- }
47
+ }
48
48
  const dao = new this.DaoConstructor({ ...this.config, authenticators: allAuthenticators }, { ...credentials })
49
49
  await dao.start()
50
50
  return dao
@@ -10,22 +10,31 @@ function promiseMap(promise, fn) {
10
10
  function prepareReactiveDaoDefinition(config, clientData) {
11
11
  if(!clientData.roles) throw new Error("no roles")
12
12
  let dao = {}
13
+ let staticDefinitions = []
13
14
  if(config.remote) {
14
- const remote = config.remote(clientData)
15
- for (let remoteName of remote) {
15
+ const remotes = config.remote(clientData)
16
+ for (let remoteName in remotes) {
17
+ const remote = remotes[remoteName]
16
18
  dao[remoteName] = {
17
19
  type: "remote",
18
20
  generator: ReactiveDao.ObservableList,
19
21
  ...remote
20
22
  }
23
+ if(remote.definition) {
24
+ staticDefinitions.push(remote.definition)
25
+ }
21
26
  }
22
27
  }
23
28
  if(config.local) {
24
- const local = config.local(clientData)
25
- for (let localName in local) {
29
+ const locals = config.local(clientData)
30
+ for (let localName in locals) {
31
+ const local = locals[localName]
26
32
  dao[localName] = {
27
33
  type: "local",
28
- source: local[localName]
34
+ source: local
35
+ }
36
+ if(local.definition) {
37
+ staticDefinitions.push(local.definition)
29
38
  }
30
39
  }
31
40
  }
@@ -109,6 +118,10 @@ function prepareReactiveDaoDefinition(config, clientData) {
109
118
  }
110
119
  }
111
120
  if(config.shareDefinition) {
121
+ const definitionsPromise = Promise.all([
122
+ ...(config.services.map(service => service.app.clientSideDefinition(service, clientData))),
123
+ ...staticDefinitions
124
+ ])
112
125
  dao['metadata'] = {
113
126
  type: "local",
114
127
  source: new ReactiveDao.SimpleDao({
@@ -125,32 +138,26 @@ function prepareReactiveDaoDefinition(config, clientData) {
125
138
  serviceDefinitions: {
126
139
  observable(parameters) {
127
140
  return new ReactiveDao.ObservablePromiseProxy(
128
- Promise.all(
129
- config.services.map(service => service.app.clientSideDefinition(service, clientData))
130
- ).then(x => new ReactiveDao.ObservableValue(x))
141
+ definitionsPromise.then(x => new ReactiveDao.ObservableValue(x))
131
142
  )
132
143
  /*let definitions = config.services.map(s => s.definition.toJSON())
133
144
  return new ReactiveDao.ObservableValue(definitions)*/
134
145
  },
135
146
  async get(parameters) {
136
- return Promise.all(config.services.map(s => s.app.clientSideDefinition(s, clientData)))
147
+ return definitionsPromise
137
148
  }
138
149
  },
139
150
  api: {
140
151
  observable(parameters) {
141
152
  return new ReactiveDao.ObservablePromiseProxy(
142
- Promise.all(
143
- config.services.map(service => service.app.clientSideDefinition(service, clientData))
144
- ).then(services => new ReactiveDao.ObservableValue({
153
+ definitionsPromise.then(services => new ReactiveDao.ObservableValue({
145
154
  client: { ...clientData, sessionKey: undefined },
146
155
  services
147
156
  }))
148
157
  )
149
158
  },
150
159
  async get(parameters) {
151
- return Promise.all(
152
- config.services.map(service => service.app.clientSideDefinition(service, clientData))
153
- ).then(services => ({
160
+ return definitionsPromise.then(services => ({
154
161
  client: { ...clientData, sessionKey: undefined },
155
162
  services
156
163
  }))
@@ -167,7 +174,8 @@ function prepareReactiveDaoDefinition(config, clientData) {
167
174
 
168
175
  class RTCMSDao extends ReactiveDao {
169
176
  constructor(config, clientData) {
170
- super(clientData.sessionId, prepareReactiveDaoDefinition(config, clientData))
177
+ console.log("CD", clientData)
178
+ super(clientData, prepareReactiveDaoDefinition(config, clientData))
171
179
  //console.log("Created dao with clientData",clientData)
172
180
  if( !clientData.roles ) throw new Error("NO ROLES!!")
173
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/framework",
3
- "version": "0.7.15",
3
+ "version": "0.7.17",
4
4
  "description": "Live Change Framework - ultimate solution for real time mobile/web apps",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "homepage": "https://github.com/live-change/live-change-framework",
23
23
  "devDependencies": {
24
- "@live-change/dao": "0.5.9",
25
- "@live-change/dao-websocket": "0.5.9",
26
- "@live-change/db": "0.5.23",
27
- "@live-change/db-store-level": "0.5.23",
28
- "@live-change/db-store-lmdb": "0.5.23",
24
+ "@live-change/dao": "0.5.10",
25
+ "@live-change/dao-websocket": "0.5.10",
26
+ "@live-change/db": "0.5.24",
27
+ "@live-change/db-store-level": "0.5.24",
28
+ "@live-change/db-store-lmdb": "0.5.24",
29
29
  "@live-change/sockjs": "0.4.1",
30
- "@live-change/uid": "0.7.11",
30
+ "@live-change/uid": "0.7.16",
31
31
  "cookie": "^0.4.1",
32
32
  "express": "^4.18.1",
33
33
  "os-service": "^2.2.0",
@@ -35,5 +35,5 @@
35
35
  "tape": "^5.3.2",
36
36
  "websocket": "^1.0.34"
37
37
  },
38
- "gitHead": "9e2d54359edb2619024512f95ba6900734e7b3a1"
38
+ "gitHead": "5380408808cfe3c6150bddc6ba809f02a4e72071"
39
39
  }