@cocreate/crud-server 1.34.0 → 1.34.2
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/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/index.js +39 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.34.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.34.1...v1.34.2) (2024-01-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* improved handling of organization object ([7798bf7](https://github.com/CoCreate-app/CoCreate-crud-server/commit/7798bf7b4feba9b0bcc226c37d890b3c6b9b5e99))
|
|
7
|
+
|
|
8
|
+
## [1.34.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.34.0...v1.34.1) (2024-01-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* getOrg query ([5a8ebf1](https://github.com/CoCreate-app/CoCreate-crud-server/commit/5a8ebf1cfa47331dbbd28e562af8e046d3a35f24))
|
|
14
|
+
* update to support new query system ([d97a68f](https://github.com/CoCreate-app/CoCreate-crud-server/commit/d97a68ff74831601fb777ab452769ebbf3870b36))
|
|
15
|
+
|
|
1
16
|
# [1.34.0](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.33.0...v1.34.0) (2024-01-08)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -64,6 +64,17 @@ class CoCreateCrudServer {
|
|
|
64
64
|
return resolve()
|
|
65
65
|
|
|
66
66
|
let organization = await this.getOrganization(data.organization_id)
|
|
67
|
+
|
|
68
|
+
// if (data.host && this.hosts[data.host])
|
|
69
|
+
// organization = await this.getHost(data.host)
|
|
70
|
+
// else
|
|
71
|
+
// organization = await this.getOrganization(data.organization_id)
|
|
72
|
+
|
|
73
|
+
// if (data.host)
|
|
74
|
+
// organization = await this.getHost(data.organization_id)
|
|
75
|
+
// else
|
|
76
|
+
// organization = await this.getOrganization(data.organization_id)
|
|
77
|
+
|
|
67
78
|
if (organization.error)
|
|
68
79
|
return resolve(organization)
|
|
69
80
|
|
|
@@ -196,7 +207,15 @@ class CoCreateCrudServer {
|
|
|
196
207
|
if (this.hosts[host]) {
|
|
197
208
|
return await this.hosts[host]
|
|
198
209
|
} else {
|
|
199
|
-
|
|
210
|
+
let organization_id = null
|
|
211
|
+
let platform = true
|
|
212
|
+
if (this.organizations[organization_id]) {
|
|
213
|
+
let org = await this.organizations[organization_id]
|
|
214
|
+
organization_id = org._id
|
|
215
|
+
platform = false
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
this.hosts[host] = this.getOrg(organization_id, host, platform)
|
|
200
219
|
this.hosts[host] = await this.hosts[host]
|
|
201
220
|
return this.hosts[host]
|
|
202
221
|
}
|
|
@@ -229,26 +248,37 @@ class CoCreateCrudServer {
|
|
|
229
248
|
data.object = [{ _id: organization_id }]
|
|
230
249
|
else if (host)
|
|
231
250
|
data.$filter = {
|
|
232
|
-
query: [
|
|
233
|
-
|
|
234
|
-
]
|
|
251
|
+
query: { host: { $elemMatch: { name: { $in: [host] } } } },
|
|
252
|
+
limit: 1
|
|
235
253
|
}
|
|
236
254
|
else
|
|
237
255
|
return { serverOrganization: false, error: 'An organization could not be found' }
|
|
238
256
|
|
|
239
|
-
if (data.organization_id === this.config.organization_id)
|
|
240
|
-
this.organizations[organization_id] = this.config
|
|
257
|
+
if (!this.organizations[data.organization_id] && data.organization_id === this.config.organization_id)
|
|
258
|
+
this.organizations[data.organization_id] = { ...this.config, isConfig: true }
|
|
241
259
|
|
|
242
260
|
let organization = await this.send(data)
|
|
243
261
|
|
|
244
262
|
if (organization
|
|
245
263
|
&& organization.object
|
|
246
264
|
&& organization.object[0]) {
|
|
265
|
+
this.organizations[organization.object[0]._id] = organization.object[0]
|
|
266
|
+
if (platform) {
|
|
267
|
+
delete data.$filter
|
|
268
|
+
data.database = data.organization_id = organization.object[0]._id
|
|
269
|
+
let org = await this.send(data)
|
|
270
|
+
if (org
|
|
271
|
+
&& org.object
|
|
272
|
+
&& org.object[0]) {
|
|
273
|
+
return org.object[0]
|
|
274
|
+
|
|
275
|
+
} else {
|
|
276
|
+
return { serverOrganization: false, error: 'An organization could not be found in the specified dbUrl' }
|
|
277
|
+
}
|
|
278
|
+
}
|
|
247
279
|
return organization.object[0]
|
|
248
|
-
} else {
|
|
249
|
-
return { serverOrganization: false, error: 'An organization could not be found' }
|
|
250
280
|
}
|
|
251
|
-
|
|
281
|
+
return { serverOrganization: false, error: 'An organization could not be found' }
|
|
252
282
|
}
|
|
253
283
|
|
|
254
284
|
|