abmp-npm 10.3.2 → 10.3.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.
@@ -1,18 +1,27 @@
1
1
  const { items } = require('@wix/data');
2
2
  const { auth } = require('@wix/essentials');
3
3
 
4
- // @wix/data does not support suppressAuth currently, so we need to elevate it
4
+ // @wix/data does not support suppressAuth currently, so we need to elevate it.
5
+ // Elevation is deferred (called per-invocation) because @wix/data's `items.*`
6
+ // methods are not guaranteed to be populated at module-load time in the Velo
7
+ // cloud runtime — accessing them eagerly throws "Cannot read properties of
8
+ // undefined (reading 'insert')" while loading the module.
9
+ const elevated =
10
+ method =>
11
+ (...args) =>
12
+ auth.elevate(items[method])(...args);
13
+
5
14
  const wixData = {
6
- insert: auth.elevate(items.insert),
7
- update: auth.elevate(items.update),
8
- bulkInsert: auth.elevate(items.bulkInsert),
9
- query: auth.elevate(items.query),
10
- save: auth.elevate(items.save),
11
- remove: auth.elevate(items.remove),
12
- get: auth.elevate(items.get),
13
- truncate: auth.elevate(items.truncate),
14
- bulkSave: auth.elevate(items.bulkSave),
15
- search: auth.elevate(items.search),
15
+ insert: elevated('insert'),
16
+ update: elevated('update'),
17
+ bulkInsert: elevated('bulkInsert'),
18
+ query: elevated('query'),
19
+ save: elevated('save'),
20
+ remove: elevated('remove'),
21
+ get: elevated('get'),
22
+ truncate: elevated('truncate'),
23
+ bulkSave: elevated('bulkSave'),
24
+ search: elevated('search'),
16
25
  //TODO: add other methods here as needed
17
26
  };
18
27
  module.exports = { wixData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abmp-npm",
3
- "version": "10.3.2",
3
+ "version": "10.3.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "check-cycles": "madge --circular .",