@cocreate/crud-server 1.34.1 → 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 +7 -0
- package/package.json +1 -1
- package/src/index.js +39 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
## [1.34.1](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.34.0...v1.34.1) (2024-01-17)
|
|
2
9
|
|
|
3
10
|
|
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,24 +248,37 @@ class CoCreateCrudServer {
|
|
|
229
248
|
data.object = [{ _id: organization_id }]
|
|
230
249
|
else if (host)
|
|
231
250
|
data.$filter = {
|
|
232
|
-
query: { host: { $elemMatch: { name: { $in: [host] } } } }
|
|
251
|
+
query: { host: { $elemMatch: { name: { $in: [host] } } } },
|
|
252
|
+
limit: 1
|
|
233
253
|
}
|
|
234
254
|
else
|
|
235
255
|
return { serverOrganization: false, error: 'An organization could not be found' }
|
|
236
256
|
|
|
237
|
-
if (data.organization_id === this.config.organization_id)
|
|
238
|
-
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 }
|
|
239
259
|
|
|
240
260
|
let organization = await this.send(data)
|
|
241
261
|
|
|
242
262
|
if (organization
|
|
243
263
|
&& organization.object
|
|
244
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
|
+
}
|
|
245
279
|
return organization.object[0]
|
|
246
|
-
} else {
|
|
247
|
-
return { serverOrganization: false, error: 'An organization could not be found' }
|
|
248
280
|
}
|
|
249
|
-
|
|
281
|
+
return { serverOrganization: false, error: 'An organization could not be found' }
|
|
250
282
|
}
|
|
251
283
|
|
|
252
284
|
|