corebasic 1.0.192 → 1.0.193

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.
Files changed (2) hide show
  1. package/libs/elabase.js +38 -2
  2. package/package.json +1 -1
package/libs/elabase.js CHANGED
@@ -52,8 +52,44 @@ export const globalMeta = args => {
52
52
  let obj = { ...args, company: "GLOBAL", outlet: "GLOBAL" }
53
53
  return {
54
54
  ...obj,
55
- setOutlet: outlet => {return {...obj, outlet}},
56
- setCompany: company => {return {...obj, company}},
55
+ setOutlet: outlet => {
56
+ if (outlet === "GLOBAL")
57
+ throw {message: "Error: Invalid outlet provided in Dip.globalMeta().setOutlet()"}
58
+ return {...obj, outlet}
59
+ },
60
+ setCompany: company => {
61
+ if (company === "GLOBAL")
62
+ throw {message: "Error: Invalid company provided in Dip.globalMeta().setCompany()"}
63
+ return {...obj, company}
64
+ },
65
+ }
66
+ }
67
+
68
+ export const customMeta = args => {
69
+ let obj = { ...args }
70
+
71
+ if (obj.company === "GLOBAL")
72
+ delete obj.company
73
+ if (obj.outlet === "GLOBAL")
74
+ delete obj.outlet
75
+
76
+ return {
77
+ ...obj,
78
+ set: (company, outlet) => {
79
+
80
+ if (typeof company !== "string" && !Array.isArray(company))
81
+ throw {message: "Error: Invalid company provided in Dip.customMeta().set()"}
82
+ if (typeof outlet !== "string" && !Array.isArray(outlet))
83
+ throw {message: "Error: Invalid outlet provided in Dip.customMeta().set()"}
84
+
85
+
86
+ if (!company || (typeof company === "string" && company.trim() === "") || company === "GLOBAL" || (Array.isArray(company) && (!company.length || company.some(item => typeof item !== "string" || item.trim() === "" || item === "GLOBAL")) ))
87
+ throw {message: "Error: Invalid company provided in Dip.customMeta().set()"}
88
+ if (!outlet || (typeof outlet === "string" && outlet.trim() === "") || outlet === "GLOBAL" || (Array.isArray(outlet) && (!outlet.length || outlet.some(item => typeof item !== "string" || item.trim() === "" || item === "GLOBAL")) ))
89
+ throw {message: "Error: Invalid outlet provided in Dip.customMeta().set()"}
90
+
91
+ return {...obj, company, outlet}
92
+ }
57
93
  }
58
94
  }
59
95
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.192",
4
+ "version": "1.0.193",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {