corebasic 1.0.192 → 1.0.194

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