@cocreate/crud-server 1.34.2 → 1.34.4

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.34.4](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.34.3...v1.34.4) (2024-02-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Removed https://cdn.cocreate.app/latest/CoCreate.min.css ([224a04d](https://github.com/CoCreate-app/CoCreate-crud-server/commit/224a04d61a65dca145a0968c41d95875ec92159e))
7
+
8
+ ## [1.34.3](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.34.2...v1.34.3) (2024-01-30)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * removed getHostOld() and getOrganizationOld() ([956c472](https://github.com/CoCreate-app/CoCreate-crud-server/commit/956c472c4ebbc8eeb36f4d612f19ec70ffba241c))
14
+
1
15
  ## [1.34.2](https://github.com/CoCreate-app/CoCreate-crud-server/compare/v1.34.1...v1.34.2) (2024-01-18)
2
16
 
3
17
 
package/docs/index.html CHANGED
@@ -17,12 +17,6 @@
17
17
  name="keywords"
18
18
  content="helper classes, utility classes, css framework, css library, inline style classes" />
19
19
  <meta name="robots" content="index,follow" />
20
-
21
- <!-- CoCreate CSS -->
22
- <link
23
- rel="stylesheet"
24
- href="https://cdn.cocreate.app/latest/CoCreate.min.css"
25
- type="text/css" />
26
20
  </head>
27
21
 
28
22
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/crud-server",
3
- "version": "1.34.2",
3
+ "version": "1.34.4",
4
4
  "description": "CoCreate-crud-server",
5
5
  "keywords": [
6
6
  "cocreate-crud",
package/src/index.js CHANGED
@@ -63,17 +63,7 @@ class CoCreateCrudServer {
63
63
  if (!data.organization_id || !this.config)
64
64
  return resolve()
65
65
 
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)
66
+ let organization = await this.getOrganization(data)
77
67
 
78
68
  if (organization.error)
79
69
  return resolve(organization)
@@ -116,7 +106,7 @@ class CoCreateCrudServer {
116
106
  }
117
107
  }
118
108
 
119
- this.send(platformUpdate)
109
+ // this.send(platformUpdate)
120
110
  }
121
111
  }
122
112
  }
@@ -203,85 +193,79 @@ class CoCreateCrudServer {
203
193
  });
204
194
  }
205
195
 
206
- async getHost(host) {
207
- if (this.hosts[host]) {
208
- return await this.hosts[host]
209
- } else {
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)
219
- this.hosts[host] = await this.hosts[host]
220
- return this.hosts[host]
221
- }
222
-
223
- }
224
196
 
225
- async getOrganization(organization_id, platform) {
226
- if (this.organizations[organization_id]) {
227
- return await this.organizations[organization_id]
197
+ async getOrganization(data) {
198
+ if (this.hosts[data.host]) {
199
+ return await this.hosts[data.host]
200
+ } else if (this.organizations[data.organization_id]) {
201
+ return await this.organizations[data.organization_id]
228
202
  } else {
229
- this.organizations[organization_id] = this.getOrg(organization_id, null, platform)
230
- this.organizations[organization_id] = await this.organizations[organization_id]
231
- return this.organizations[organization_id]
203
+ if (data.organization_id) {
204
+ this.organizations[data.organization_id] = this.getOrg(data)
205
+ this.organizations[data.organization_id] = await this.organizations[data.organization_id]
206
+ return this.organizations[data.organization_id]
207
+ } else if (data.host) {
208
+ // this.hosts[data.host] = this.getOrg(data)
209
+ this.hosts[data.host] = await this.getOrg(data)
210
+ return this.hosts[data.host]
211
+ }
232
212
  }
233
213
  }
234
214
 
235
- async getOrg(organization_id, host, platform = true) {
236
- let data = {
215
+ async getOrg(data) {
216
+ let query = {
237
217
  method: 'object.read',
238
- host,
218
+ host: data.host,
239
219
  database: this.config.organization_id,
240
220
  array: 'organizations',
241
221
  organization_id: this.config.organization_id
242
222
  }
243
223
 
244
- if (!platform)
245
- data.database = data.organization_id = organization_id
224
+ if (this.organizations[data.organization_id])
225
+ data.database = data.organization_id = data.organization_id
246
226
 
247
- if (organization_id)
248
- data.object = [{ _id: organization_id }]
249
- else if (host)
250
- data.$filter = {
251
- query: { host: { $elemMatch: { name: { $in: [host] } } } },
227
+ if (data.organization_id)
228
+ query.object = [{ _id: data.organization_id }]
229
+ else if (data.host)
230
+ query.$filter = {
231
+ query: { host: { $elemMatch: { name: { $in: [data.host] } } } },
252
232
  limit: 1
253
233
  }
254
234
  else
255
235
  return { serverOrganization: false, error: 'An organization could not be found' }
256
236
 
257
- if (!this.organizations[data.organization_id] && data.organization_id === this.config.organization_id)
258
- this.organizations[data.organization_id] = { ...this.config, isConfig: true }
237
+ if (!this.organizations[query.organization_id] && query.organization_id === this.config.organization_id)
238
+ this.organizations[query.organization_id] = { ...this.config, isConfig: true }
259
239
 
260
- let organization = await this.send(data)
240
+ let organization = await this.send(query)
261
241
 
262
242
  if (organization
263
243
  && organization.object
264
244
  && 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)
245
+ if (!this.organizations[organization.object[0]._id] || this.organizations[query.organization_id].isConfig) {
246
+ this.organizations[organization.object[0]._id] = organization.object[0]
247
+
248
+ delete query.$filter
249
+ query.database = query.organization_id = organization.object[0]._id
250
+ let org = await this.send(query)
270
251
  if (org
271
252
  && org.object
272
253
  && org.object[0]) {
254
+ if (data.host)
255
+ this.hosts[data.host] = org.object[0]
273
256
  return org.object[0]
274
-
275
257
  } else {
276
258
  return { serverOrganization: false, error: 'An organization could not be found in the specified dbUrl' }
277
259
  }
260
+ } else {
261
+ if (data.host)
262
+ this.hosts[data.host] = organization.object[0]
263
+ return organization.object[0]
278
264
  }
279
- return organization.object[0]
280
265
  }
281
266
  return { serverOrganization: false, error: 'An organization could not be found' }
282
267
  }
283
268
 
284
-
285
269
  errorHandler(data, error, database, array) {
286
270
  if (typeof error == 'object')
287
271
  error['storage'] = 'mongodb'