corebasic 1.0.124 → 1.0.126
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/libs/elabase.js +18 -1
- package/libs/features.js +1 -1
- package/package.json +1 -1
package/libs/elabase.js
CHANGED
|
@@ -91,6 +91,7 @@ export const insert = async (meta, collection, value, _id) => {
|
|
|
91
91
|
if (typeof value === "object" && !Array.isArray(value))
|
|
92
92
|
value.company = meta.company
|
|
93
93
|
}
|
|
94
|
+
value.outlet = value.outlet ?? meta.outlet
|
|
94
95
|
// ---------------------
|
|
95
96
|
|
|
96
97
|
var arg = {
|
|
@@ -102,6 +103,13 @@ export const insert = async (meta, collection, value, _id) => {
|
|
|
102
103
|
if (_id)
|
|
103
104
|
arg._id = _id
|
|
104
105
|
|
|
106
|
+
if (!(["string", "number"].includes(typeof arg?._id)))
|
|
107
|
+
throw {message: "Error: invalid _id in Dip.insert()"}
|
|
108
|
+
if (typeof arg?._id === "string" && arg._id.trim().length === 0)
|
|
109
|
+
throw {message: "Error: invalid _id in Dip.insert()"}
|
|
110
|
+
|
|
111
|
+
if ((!arg._id && arg._id !== 0))
|
|
112
|
+
|
|
105
113
|
if (isTransaction) {
|
|
106
114
|
transactions.push(arg)
|
|
107
115
|
return
|
|
@@ -166,8 +174,17 @@ export const update = async (meta, collection, query, update, options) => {
|
|
|
166
174
|
query.company = meta.company
|
|
167
175
|
update.$set = update.$set ?? {}
|
|
168
176
|
update.$set.company = meta.company
|
|
169
|
-
if (
|
|
177
|
+
if (options?.upsert) {
|
|
178
|
+
update.$setOnInsert = update.$setOnInsert ?? {}
|
|
170
179
|
update.$setOnInsert.company = meta.company
|
|
180
|
+
update.$setOnInsert.outlet = update.$setOnInsert.outlet ?? update.$set?.outlet ?? meta.outlet
|
|
181
|
+
|
|
182
|
+
let _id = update.$setOnInsert._id ?? update.$set?._id ?? query?._id
|
|
183
|
+
if (!(["string", "number"].includes(typeof _id)))
|
|
184
|
+
throw {message: "Error: invalid _id in Dip.update() with upsert"}
|
|
185
|
+
if (typeof _id === "string" && _id.trim().length === 0)
|
|
186
|
+
throw {message: "Error: invalid _id in Dip.update() with upsert"}
|
|
187
|
+
}
|
|
171
188
|
}
|
|
172
189
|
// ---------------------
|
|
173
190
|
|
package/libs/features.js
CHANGED
|
@@ -19,7 +19,7 @@ async function loadLocalFeatures() { // For Local Testing
|
|
|
19
19
|
let data = {}
|
|
20
20
|
if (process.env.LOAD_LOCAL_FEATURES) {
|
|
21
21
|
try {
|
|
22
|
-
let url = process.env.
|
|
22
|
+
let url = process.env.LOAD_LOCAL_FEATURES_URL ? `${process.env.LOAD_LOCAL_FEATURES_URL}/features` : 'https://slyp.app/slyp-dev/api/v1/features'
|
|
23
23
|
let result = (await axios.get(url, { data: {}, headers: {jwt: SERVICE_ACCESS_TOKEN, service: true}, timeout: 3000 })).data
|
|
24
24
|
await Utils.stringToFile('/slyp.local.features.json', JSON.stringify(result.data, null, '\t'))
|
|
25
25
|
} catch {
|