@cocreate/file 1.7.0 → 1.7.1

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,12 @@
1
+ ## [1.7.1](https://github.com/CoCreate-app/CoCreate-file/compare/v1.7.0...v1.7.1) (2023-09-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * renamed filter to $filter ([c8e8390](https://github.com/CoCreate-app/CoCreate-file/commit/c8e83901429d2c370b327449a9f7f0081b03e6fd))
7
+ * update broadcast to broadcastSender false ([b93ca93](https://github.com/CoCreate-app/CoCreate-file/commit/b93ca93f6b1bff1b1052c841f63919f4156e551e))
8
+ * update data.filter to data.$filter, supports data.object.$filter to ad filters per object ([7ccb455](https://github.com/CoCreate-app/CoCreate-file/commit/7ccb45521a8af3c67587c756c905d7ed4a557a60))
9
+
1
10
  # [1.7.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.6.3...v1.7.0) (2023-09-07)
2
11
 
3
12
 
@@ -22,4 +22,4 @@ module.exports = {
22
22
  }
23
23
  }
24
24
  ]
25
- }
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/file",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "A headless file uploader that uses HTML5 attributes for customization. Allows easy upload of files to server.",
5
5
  "keywords": [
6
6
  "file",
package/src/client.js CHANGED
@@ -15,10 +15,12 @@
15
15
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
16
  ********************************************************************************/
17
17
 
18
- // Commercial Licensing Information:
19
- // For commercial use of this software without the copyleft provisions of the AGPLv3,
20
- // you must obtain a commercial license from CoCreate LLC.
21
- // For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
18
+ /**
19
+ * Commercial Licensing Information:
20
+ * For commercial use of this software without the copyleft provisions of the AGPLv3,
21
+ * you must obtain a commercial license from CoCreate LLC.
22
+ * For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
23
+ */
22
24
 
23
25
  import Observer from '@cocreate/observer';
24
26
  import Crud from '@cocreate/crud-client';
@@ -389,7 +391,7 @@ async function upload(element, data) {
389
391
  let Data = Elements.getObject(input);
390
392
  if (Data.type) {
391
393
  if (input.getFilter)
392
- Data.filter = input.getFilter()
394
+ Data.$filter = input.getFilter()
393
395
 
394
396
  let files = await getFiles(input)
395
397
 
@@ -406,18 +408,16 @@ async function upload(element, data) {
406
408
  }
407
409
  }
408
410
 
409
- let action = 'update' + Data.type.charAt(0).toUpperCase() + Data.type.slice(1)
410
- if (Crud[action]) {
411
- let response = await Crud[action](Data)({
412
- array,
413
- object,
414
- upsert: true
415
- });
416
-
417
- data.push(response)
418
- if (response && (!object || object !== response.object)) {
419
- Elements.setTypeValue(element, response);
420
- }
411
+ Data.method = 'update.' + Data.type
412
+ let response = await Crud.send(Data)({
413
+ array,
414
+ object,
415
+ upsert: true
416
+ });
417
+
418
+ data.push(response)
419
+ if (response && (!object || object !== response.object)) {
420
+ Elements.setTypeValue(element, response);
421
421
  }
422
422
  }
423
423
  }
@@ -471,7 +471,7 @@ async function Import(element, data) {
471
471
  let Data = Elements.getObject(element[i]);
472
472
  if (Data.type) {
473
473
  if (element[i].getFilter)
474
- Data.filter = element[i].getFilter()
474
+ Data.$filter = element[i].getFilter()
475
475
 
476
476
  if (Data.type === 'key')
477
477
  Data.type = 'object'
@@ -482,10 +482,8 @@ async function Import(element, data) {
482
482
 
483
483
  if (data.length) {
484
484
  for (let i = 0; i < data.length; i++) {
485
- let action = 'create' + data[i].type.charAt(0).toUpperCase() + data[i].type.slice(1)
486
- if (Crud[action]) {
487
- data[i] = await Crud[action](data[i])
488
- }
485
+ data[i].method = 'create.' + data[i].type
486
+ data[i] = await Crud.send(data[i])
489
487
  }
490
488
  }
491
489
 
@@ -523,15 +521,14 @@ async function Export(element, data) {
523
521
  let Data = Elements.getObject(element[i]);
524
522
  if (Data.type) {
525
523
  if (element[i].getFilter)
526
- Data.filter = element[i].getFilter()
524
+ Data.$filter = element[i].getFilter()
527
525
 
528
526
  if (Data.type === 'key')
529
527
  Data.type = 'object'
530
- let action = 'read' + Data.type.charAt(0).toUpperCase() + Data.type.slice(1)
531
- if (Crud[action]) {
532
- Data = await Crud[action](Data)
533
- data.push(...Data[Data.type])
534
- }
528
+ Data.method = 'read.' + Data.type
529
+ Data = await Crud.send(Data)
530
+ data.push(...Data[Data.type])
531
+
535
532
  }
536
533
 
537
534
  let queriedElements = queryElements({ element: element[i], prefix: 'export' })
package/src/index.js CHANGED
@@ -15,10 +15,12 @@
15
15
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
16
  ********************************************************************************/
17
17
 
18
- // Commercial Licensing Information:
19
- // For commercial use of this software without the copyleft provisions of the AGPLv3,
20
- // you must obtain a commercial license from CoCreate LLC.
21
- // For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
18
+ /**
19
+ * Commercial Licensing Information:
20
+ * For commercial use of this software without the copyleft provisions of the AGPLv3,
21
+ * you must obtain a commercial license from CoCreate LLC.
22
+ * For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
23
+ */
22
24
 
23
25
  (function (root, factory) {
24
26
  if (typeof define === 'function' && define.amd) {
package/src/server.js CHANGED
@@ -121,13 +121,13 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
121
121
 
122
122
 
123
123
  crud.socket.create(config)
124
- config.broadcast = false
124
+ config.broadcastSender = false
125
125
 
126
126
  if (config.email && config.password) {
127
127
  let request = {
128
128
  method: 'signIn',
129
129
  array: 'users',
130
- filter: {
130
+ $filter: {
131
131
  query: [
132
132
  { key: 'email', value: config.email, operator: '$eq' },
133
133
  { key: 'password', value: config.password, operator: '$eq' }
@@ -275,8 +275,8 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
275
275
  }
276
276
 
277
277
  if (!newObject.object._id)
278
- newObject.filter = {
279
- query: [{ key: 'path', value: pathName, operator: '$eq' }]
278
+ newObject.$filter = {
279
+ query: [{ key: 'path', value: pathName, operator: '$or' }]
280
280
  }
281
281
 
282
282
  response = await runStore(newObject);
@@ -378,8 +378,8 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
378
378
 
379
379
  let data = { array, object }
380
380
  if (!object._id && object.path)
381
- data.filter = {
382
- query: [{ key: 'path', value: object.path, operator: '$eq' }]
381
+ data.$filter = {
382
+ query: [{ key: 'path', value: object.path, operator: '$or' }]
383
383
  }
384
384
 
385
385
  if (match.length && isMatch)
@@ -408,7 +408,7 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
408
408
  async function runStore(data) {
409
409
  try {
410
410
  let response;
411
- if (!data.object._id && !data.filter) {
411
+ if (!data.object._id && !data.$filter) {
412
412
  response = await crud.send({
413
413
  method: 'create.object',
414
414
  ...config,