@cocreate/crud-server 1.28.2 → 1.28.3
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 +9 -0
- package/LICENSE +656 -551
- package/package.json +2 -2
- package/src/index.js +22 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/crud-server",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.3",
|
|
4
4
|
"description": "CoCreate-crud-server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cocreate-crud",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"url": "git+https://github.com/CoCreate-app/CoCreate-crud-server.git"
|
|
35
35
|
},
|
|
36
36
|
"author": "CoCreate LLC",
|
|
37
|
-
"license": "
|
|
37
|
+
"license": "AGPL-3.0",
|
|
38
38
|
"bugs": {
|
|
39
39
|
"url": "https://github.com/CoCreate-app/CoCreate-crud-server/issues"
|
|
40
40
|
},
|
package/src/index.js
CHANGED
|
@@ -49,18 +49,14 @@ class CoCreateCrudServer {
|
|
|
49
49
|
for (let i = 0; i < method.length; i++) {
|
|
50
50
|
for (let j = 0; j < type.length; j++) {
|
|
51
51
|
const action = method[i] + '.' + type[j];
|
|
52
|
-
this.wsManager.on(action, (
|
|
52
|
+
this.wsManager.on(action, (data) =>
|
|
53
|
+
this.send(data))
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
async send(data) {
|
|
59
|
-
data = await this.crud('', data)
|
|
60
|
-
return data
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async crud(socket, data) {
|
|
64
60
|
return new Promise(async (resolve) => {
|
|
65
61
|
try {
|
|
66
62
|
if (!data.organization_id || !this.config)
|
|
@@ -121,9 +117,7 @@ class CoCreateCrudServer {
|
|
|
121
117
|
if (data.method.startsWith('update') && data.upsert != false)
|
|
122
118
|
data.upsert = true
|
|
123
119
|
|
|
124
|
-
|
|
125
|
-
// TODO: support stats from multiple dbs
|
|
126
|
-
if (data.array || data.method === 'databaseStats') {
|
|
120
|
+
if (data.array) {
|
|
127
121
|
if (!data.database)
|
|
128
122
|
data['database'] = data.organization_id
|
|
129
123
|
|
|
@@ -150,7 +144,7 @@ class CoCreateCrudServer {
|
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
146
|
|
|
153
|
-
this
|
|
147
|
+
this.send(platformUpdate)
|
|
154
148
|
}
|
|
155
149
|
|
|
156
150
|
}
|
|
@@ -169,21 +163,23 @@ class CoCreateCrudServer {
|
|
|
169
163
|
if (storage.provider && this.databases[storage.provider]) {
|
|
170
164
|
if (!Array.isArray(storage.url))
|
|
171
165
|
storage.url = [storage.url]
|
|
172
|
-
|
|
166
|
+
|
|
167
|
+
for (let j = 0; j < storage.url.length; j++) {
|
|
173
168
|
data['storageName'] = data.storage[i]
|
|
174
|
-
data['storageUrl'] = storage.url[
|
|
175
|
-
|
|
169
|
+
data['storageUrl'] = storage.url[j]
|
|
170
|
+
|
|
171
|
+
data = await this.databases[storage.provider].send(data)
|
|
176
172
|
}
|
|
177
173
|
|
|
178
|
-
if (data
|
|
174
|
+
if (data.$filter) {
|
|
179
175
|
if (!data.type)
|
|
180
176
|
data.type = data.method.split('.').pop()
|
|
181
|
-
if (data
|
|
182
|
-
data[data.type] = sortData(array, data
|
|
183
|
-
if (data
|
|
184
|
-
data[data.type] = data[data.type].slice(data
|
|
185
|
-
|
|
186
|
-
data
|
|
177
|
+
if (data.$filter.sort && data.$filter.sort.length)
|
|
178
|
+
data[data.type] = sortData(array, data.$filter.sort)
|
|
179
|
+
if (data.$filter.index && data.$filter.limit)
|
|
180
|
+
data[data.type] = data[data.type].slice(data.$filter.index, data.$filter.limit)
|
|
181
|
+
|
|
182
|
+
data.$filter.count = data[data.type].length
|
|
187
183
|
}
|
|
188
184
|
|
|
189
185
|
}
|
|
@@ -193,26 +189,26 @@ class CoCreateCrudServer {
|
|
|
193
189
|
delete data.storageUrl
|
|
194
190
|
delete data.storageName
|
|
195
191
|
|
|
196
|
-
if (socket) {
|
|
197
|
-
if (data.organization_id === this.config.organization_id && socket.config.organization_id !== data.organization_id) {
|
|
192
|
+
if (data.socket) {
|
|
193
|
+
if (data.organization_id === this.config.organization_id && data.socket.config.organization_id !== data.organization_id) {
|
|
198
194
|
this.wsManager.broadcast({
|
|
199
195
|
config: {
|
|
200
196
|
organization_id: this.config.organization_id,
|
|
201
197
|
}
|
|
202
198
|
}, { ...data });
|
|
203
|
-
data.organization_id = socket.config.organization_id
|
|
199
|
+
data.organization_id = data.socket.config.organization_id
|
|
204
200
|
}
|
|
205
201
|
|
|
206
|
-
this.wsManager.broadcast(
|
|
202
|
+
this.wsManager.broadcast(data);
|
|
207
203
|
process.emit('changed-object', data)
|
|
208
204
|
resolve()
|
|
209
205
|
} else {
|
|
210
206
|
resolve(data)
|
|
211
207
|
}
|
|
212
208
|
} catch (error) {
|
|
213
|
-
if (socket) {
|
|
209
|
+
if (data.socket) {
|
|
214
210
|
this.errorHandler(data, error)
|
|
215
|
-
this.wsManager.send(
|
|
211
|
+
this.wsManager.send(data);
|
|
216
212
|
resolve()
|
|
217
213
|
} else {
|
|
218
214
|
resolve(data)
|