corebasic 1.0.121 → 1.0.123
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 +10 -2
- package/libs/privileges.js +8 -3
- package/package.json +1 -1
package/libs/elabase.js
CHANGED
|
@@ -95,7 +95,9 @@ export const insert = async (meta, collection, value, _id) => {
|
|
|
95
95
|
|
|
96
96
|
var arg = {
|
|
97
97
|
collection: collection,
|
|
98
|
-
insert: value
|
|
98
|
+
insert: value,
|
|
99
|
+
...(meta.DIP_URL ? {DIP_URL: meta.DIP_URL} : {}),
|
|
100
|
+
...(meta.DIP_DB ? {db: meta.DIP_DB} : {}),
|
|
99
101
|
}
|
|
100
102
|
if (_id)
|
|
101
103
|
arg._id = _id
|
|
@@ -126,6 +128,8 @@ export const query = async (meta, collection, query, options) => {
|
|
|
126
128
|
collection: collection,
|
|
127
129
|
query: query,
|
|
128
130
|
options: options ? options : {},
|
|
131
|
+
...(meta.DIP_URL ? {DIP_URL: meta.DIP_URL} : {}),
|
|
132
|
+
...(meta.DIP_DB ? {db: meta.DIP_DB} : {}),
|
|
129
133
|
}
|
|
130
134
|
if (isTransaction) {
|
|
131
135
|
transactions.push(arg)
|
|
@@ -172,6 +176,8 @@ export const update = async (meta, collection, query, update, options) => {
|
|
|
172
176
|
query: query,
|
|
173
177
|
update: update,
|
|
174
178
|
options: options ? options : {},
|
|
179
|
+
...(meta.DIP_URL ? {DIP_URL: meta.DIP_URL} : {}),
|
|
180
|
+
...(meta.DIP_DB ? {db: meta.DIP_DB} : {}),
|
|
175
181
|
}
|
|
176
182
|
if (isTransaction) {
|
|
177
183
|
transactions.push(arg)
|
|
@@ -198,6 +204,8 @@ export const remove = async (meta, collection, query) => {
|
|
|
198
204
|
collection: collection,
|
|
199
205
|
query: query,
|
|
200
206
|
delete: true,
|
|
207
|
+
...(meta.DIP_URL ? {DIP_URL: meta.DIP_URL} : {}),
|
|
208
|
+
...(meta.DIP_DB ? {db: meta.DIP_DB} : {}),
|
|
201
209
|
}
|
|
202
210
|
if (isTransaction) {
|
|
203
211
|
transactions.push(arg)
|
|
@@ -237,7 +245,7 @@ function execute(arg) {
|
|
|
237
245
|
|
|
238
246
|
return config.useDipper ? dipper(arg)
|
|
239
247
|
: axios
|
|
240
|
-
.post(fullurl, arg)
|
|
248
|
+
.post(arg.DIP_URL ?? fullurl, {...arg, DIP_URL: undefined})
|
|
241
249
|
// .timeout(5000)
|
|
242
250
|
.then(result => {
|
|
243
251
|
// console.log(res.status);
|
package/libs/privileges.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Dip from './dip.js'
|
|
4
4
|
|
|
5
|
+
let DIP_URL = process.env.PRIVELEGE_DIP_URL
|
|
6
|
+
let DIP_DB = process.env.PRIVELEGE_DIP_DB
|
|
5
7
|
|
|
6
8
|
let PRIVILEGES_CACHE = {
|
|
7
9
|
|
|
@@ -23,7 +25,7 @@ let PRIVILEGES_CACHE = {
|
|
|
23
25
|
|
|
24
26
|
const get = async (company) => {
|
|
25
27
|
PRIVILEGES_CACHE[company] = {}
|
|
26
|
-
let meta = {company, outlet: "GLOBAL"}
|
|
28
|
+
let meta = {company, outlet: "GLOBAL", DIP_URL, DIP_DB}
|
|
27
29
|
let privileges = await Dip.query(meta, "privileges", { })
|
|
28
30
|
privileges.forEach(privilege => PRIVILEGES_CACHE[company][privilege.name] = privilege)
|
|
29
31
|
|
|
@@ -35,7 +37,7 @@ const get = async (company) => {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export const start = async () => {
|
|
38
|
-
let meta = {company: "GLOBAL", outlet: "GLOBAL"}
|
|
40
|
+
let meta = {company: "GLOBAL", outlet: "GLOBAL", DIP_URL, DIP_DB}
|
|
39
41
|
let companies = await Dip.query(meta, "companies", { })
|
|
40
42
|
for (let company of companies)
|
|
41
43
|
await get(company._id)
|
|
@@ -75,10 +77,13 @@ const check = async (company, user, feature, req) => {
|
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
export const checkRequest = async (req) => {
|
|
78
|
-
let meta = {...req.body, data: undefined}
|
|
80
|
+
let meta = {...req.body, data: undefined, DIP_URL, DIP_DB}
|
|
79
81
|
req.meta = meta
|
|
80
82
|
if (req.body.feature === 'outlets.query.list') // Starting point for atleast selecting an outlet. (This is a Special Case)
|
|
81
83
|
return true
|
|
84
|
+
if (req.body.app === "Slyp")
|
|
85
|
+
return true
|
|
86
|
+
|
|
82
87
|
return await check(req.body.company, req.body.user, req.body.feature, req)
|
|
83
88
|
}
|
|
84
89
|
|