w-web-perm 1.0.0 → 1.0.1

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.
@@ -813,7 +813,7 @@
813
813
  <br class="clear">
814
814
 
815
815
  <footer>
816
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Jul 19 2023 12:50:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
816
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Jul 20 2023 00:07:52 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
817
817
  </footer>
818
818
 
819
819
  <script>prettyPrint();</script>
@@ -286,7 +286,7 @@ function WWebPerm(WOrm, url, db, getUserByToken, opt = {}) {
286
286
  //userFind
287
287
  let userFind = await woItems.users.select({ [mappingBy]: vSelf, isActive: 'y' })
288
288
  userFind = get(userFind, 0, null)
289
- console.log('userFind', userFind)
289
+ // console.log('userFind', userFind)
290
290
 
291
291
  //複寫isAdmin
292
292
  let isAdminSrc = get(userSelf, 'isAdmin', '')
@@ -294,7 +294,7 @@ function WWebPerm(WOrm, url, db, getUserByToken, opt = {}) {
294
294
  if (isAdminSrc !== isAdminSelf) {
295
295
  userFind.isAdmin = isAdminSelf
296
296
  }
297
- console.log('userFind(isAdmin)', userFind)
297
+ // console.log('userFind(isAdmin)', userFind)
298
298
 
299
299
  return userFind
300
300
  }
@@ -339,7 +339,7 @@ function WWebPerm(WOrm, url, db, getUserByToken, opt = {}) {
339
339
  // console.log('userFind', userFind)
340
340
 
341
341
  //ruleGroups
342
- let ruleGroups = await woItems.ruleGroups.select({})
342
+ let ruleGroups = await woItems.ruleGroups.select()
343
343
  // console.log('ruleGroups', ruleGroups)
344
344
 
345
345
  //targets
@@ -358,7 +358,7 @@ function WWebPerm(WOrm, url, db, getUserByToken, opt = {}) {
358
358
 
359
359
  return {
360
360
  user: userFind,
361
- roles: urs,
361
+ rules: urs,
362
362
  }
363
363
  }
364
364
 
@@ -545,7 +545,7 @@ export default WWebPerm
545
545
  <br class="clear">
546
546
 
547
547
  <footer>
548
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Jul 19 2023 12:50:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
548
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Jul 20 2023 00:07:52 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
549
549
  </footer>
550
550
 
551
551
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Jul 19 2023 12:50:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Jul 20 2023 00:07:52 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-web-perm",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/w-web-perm.umd.js",
5
5
  "dependencies": {
6
6
  "@mdi/js": "^7.2.96",
@@ -72,4 +72,4 @@
72
72
  ],
73
73
  "author": "yuda-lyu(semisphere)",
74
74
  "license": "MIT"
75
- }
75
+ }
@@ -239,7 +239,7 @@ function WWebPerm(WOrm, url, db, getUserByToken, opt = {}) {
239
239
  //userFind
240
240
  let userFind = await woItems.users.select({ [mappingBy]: vSelf, isActive: 'y' })
241
241
  userFind = get(userFind, 0, null)
242
- console.log('userFind', userFind)
242
+ // console.log('userFind', userFind)
243
243
 
244
244
  //複寫isAdmin
245
245
  let isAdminSrc = get(userSelf, 'isAdmin', '')
@@ -247,7 +247,7 @@ function WWebPerm(WOrm, url, db, getUserByToken, opt = {}) {
247
247
  if (isAdminSrc !== isAdminSelf) {
248
248
  userFind.isAdmin = isAdminSelf
249
249
  }
250
- console.log('userFind(isAdmin)', userFind)
250
+ // console.log('userFind(isAdmin)', userFind)
251
251
 
252
252
  return userFind
253
253
  }
@@ -292,7 +292,7 @@ function WWebPerm(WOrm, url, db, getUserByToken, opt = {}) {
292
292
  // console.log('userFind', userFind)
293
293
 
294
294
  //ruleGroups
295
- let ruleGroups = await woItems.ruleGroups.select({})
295
+ let ruleGroups = await woItems.ruleGroups.select()
296
296
  // console.log('ruleGroups', ruleGroups)
297
297
 
298
298
  //targets
@@ -311,7 +311,7 @@ function WWebPerm(WOrm, url, db, getUserByToken, opt = {}) {
311
311
 
312
312
  return {
313
313
  user: userFind,
314
- roles: urs,
314
+ rules: urs,
315
315
  }
316
316
  }
317
317
 
package/src/perm.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import axios from 'axios'
2
2
  import isestr from 'wsemi/src/isestr.mjs'
3
- import genPm from 'wsemi/src/genPm.mjs'
4
3
 
5
4
 
6
5
  let _url = ''
@@ -11,42 +10,48 @@ function iniPerm(url) {
11
10
  }
12
11
 
13
12
 
14
- async function getPerm(token) {
13
+ function getPerm(token = '') {
15
14
 
16
15
  //check
17
16
  if (!isestr(_url)) {
18
17
  throw new Error(`invalid url, need to use iniPerm to set url`)
19
18
  }
20
19
 
21
- //pm
22
- let pm = genPm()
20
+ // //pm
21
+ // let pm = genPm()
23
22
 
24
23
  //url
25
- let url = `${_url}?token=${token}`
24
+ let url = ''
25
+ if (isestr(token)) {
26
+ url = `${_url}?token=${token}`
27
+ }
28
+ else {
29
+ url = _url
30
+ }
26
31
 
27
32
  //axios
28
- await axios({
33
+ let pm = axios({
29
34
  method: 'get',
30
35
  url,
31
36
  // headers: { 'Content-Type': 'application/json; charset=utf-8' },
32
37
  // data: rin,
33
38
  })
34
- .then((res) => {
35
- // console.log(res)
36
- let r = {
37
- msg: '成功取得使用者權限',
38
- res,
39
- }
40
- pm.resolve(r)
41
- })
42
- .catch((err) => {
43
- // console.log(err)
44
- let r = {
45
- msg: '取得使用者權限發生錯誤',
46
- res: err,
47
- }
48
- pm.reject(r)
49
- })
39
+ // .then((res) => {
40
+ // console.log(res)
41
+ // let r = {
42
+ // msg: '成功取得使用者權限',
43
+ // res,
44
+ // }
45
+ // pm.resolve(r)
46
+ // })
47
+ // .catch((err) => {
48
+ // console.log(err)
49
+ // let r = {
50
+ // msg: '取得使用者權限發生錯誤',
51
+ // res: err,
52
+ // }
53
+ // pm.reject(r)
54
+ // })
50
55
 
51
56
  return pm
52
57
  }
@@ -1,169 +1,17 @@
1
1
  //前後端共用函數區
2
- // import min from 'lodash/min'
3
- // import size from 'lodash/size'
4
- // import take from 'lodash/take'
5
- // import isEqual from 'lodash/isEqual'
6
- import uniq from 'lodash/uniq'
7
- // import set from 'lodash/set'
8
2
  import get from 'lodash/get'
9
3
  import each from 'lodash/each'
10
4
  import map from 'lodash/map'
11
5
  import find from 'lodash/find'
12
- import filter from 'lodash/filter'
13
- // import last from 'lodash/last'
14
- // import size from 'lodash/size'
15
- import split from 'lodash/split'
16
6
  import join from 'lodash/join'
17
7
  import cloneDeep from 'lodash/cloneDeep'
18
8
  import takeRight from 'lodash/takeRight'
19
9
  import dropRight from 'lodash/dropRight'
20
10
  import sortBy from 'lodash/sortBy'
21
11
  import sep from 'wsemi/src/sep.mjs'
22
- import isarr from 'wsemi/src/isarr.mjs'
23
- import isstr from 'wsemi/src/isstr.mjs'
24
12
  import iseobj from 'wsemi/src/iseobj.mjs'
25
13
  import haskey from 'wsemi/src/haskey.mjs'
26
14
  import composeToTree from 'wsemi/src/composeToTree.mjs'
27
- // import getFileAccept from 'wsemi/src/getFileAccept.mjs'
28
-
29
-
30
- // function atSep(attachmentsIds) {
31
-
32
- // //ts
33
- // let ts = sep(attachmentsIds, ';')
34
-
35
- // return ts
36
- // }
37
-
38
-
39
- // function atJoin(ts) {
40
-
41
- // //uniq
42
- // ts = uniq(ts)
43
-
44
- // //str
45
- // let str = join(ts, ';')
46
-
47
- // return str
48
- // }
49
-
50
-
51
- // function atParse(attachmentsIds) {
52
-
53
- // //ts
54
- // let ts = atSep(attachmentsIds)
55
-
56
- // //ids
57
- // let ids = map(ts, (v) => {
58
- // let s = sep(v, '@')
59
- // let table = get(s, 0, '')
60
- // let id = get(s, 1, '')
61
- // if (table === '') {
62
- // console.log('atParse: invalid table in attachmentsIds', attachmentsIds)
63
- // }
64
- // if (id === '') {
65
- // console.log('atParse: invalid id in attachmentsIds', attachmentsIds)
66
- // }
67
- // return {
68
- // table,
69
- // id,
70
- // }
71
- // })
72
-
73
- // return ids
74
- // }
75
-
76
-
77
- // function atRemove(inp, removeId, opt = {}) {
78
-
79
- // //removeId
80
- // if (!isstr(removeId)) {
81
- // removeId = ''
82
- // }
83
- // if (removeId.indexOf('@') >= 0) {
84
- // removeId = split(removeId, '@')[1] //取後面id
85
- // }
86
-
87
- // //ids
88
- // let ids = []
89
- // let returnTypeTemp = ''
90
- // if (isarr(inp)) {
91
- // ids = inp
92
- // returnTypeTemp = 'array'
93
- // }
94
- // else if (isstr(inp)) {
95
- // ids = atParse(inp)
96
- // returnTypeTemp = 'string'
97
- // }
98
-
99
- // //returnType
100
- // let returnType = get(opt, 'returnType', null)
101
- // if (returnType !== 'array' && returnType !== 'string') {
102
- // returnType = returnTypeTemp
103
- // }
104
-
105
-
106
- // //filter
107
- // ids = filter(ids, (v) => {
108
- // return v.id !== removeId
109
- // })
110
-
111
- // if (returnType === 'array') {
112
- // return ids
113
- // }
114
- // return atMerge(ids)
115
- // }
116
-
117
-
118
- // function atMerge(ids) {
119
-
120
- // //ts
121
- // let ts = map(ids, (v) => {
122
- // let table = get(v, 'table', '')
123
- // let id = get(v, 'id', '')
124
- // if (table === '') {
125
- // console.log('atMerge: invalid table in ids', ids)
126
- // }
127
- // if (id === '') {
128
- // console.log('atMerge: invalid id in ids', ids)
129
- // }
130
- // return `${table}@${id}`
131
- // })
132
-
133
- // return atJoin(ts)
134
- // }
135
-
136
-
137
- // function isNumOrEng(str) {
138
- // let regExp = /^[\d|a-zA-Z]+$/
139
- // if (regExp.test(str)) {
140
- // return true
141
- // }
142
- // else {
143
- // return false
144
- // }
145
- // }
146
-
147
-
148
- // function extractFileType(fileName, fileType) {
149
- // let r = ''
150
-
151
- // //find
152
- // let ar = getFileAccept()
153
- // for (let i = 0; i < ar.length; i++) {
154
- // if (ar[i].acp === fileType) {
155
- // return ar[i].name
156
- // }
157
- // }
158
-
159
- // //from name ext
160
- // let s = split(fileName, '.')
161
- // if (size(s) > 1) {
162
- // return last(s)
163
- // }
164
-
165
- // return r
166
- // }
167
15
 
168
16
 
169
17
  function getAllBlocks(targets) {
@@ -61,7 +61,7 @@ let funNew = (ndata = {}) => {
61
61
  o.userIdUpdate = o.userId
62
62
  o.timeCreate = nowms2str()
63
63
  o.timeUpdate = o.timeCreate
64
- o.isActive = 'y'
64
+ // o.isActive = 'y'
65
65
  return o
66
66
  }
67
67
 
@@ -3,7 +3,7 @@ import keys from 'lodash/keys'
3
3
  import genID from 'wsemi/src/genID.mjs'
4
4
  import dtmapping from 'wsemi/src/dtmapping.mjs'
5
5
  import dtpick from 'wsemi/src/dtpick.mjs'
6
- import nowms2str from 'wsemi/src/nowms2str.mjs'
6
+ // import nowms2str from 'wsemi/src/nowms2str.mjs'
7
7
  import now2strp from 'wsemi/src/now2strp.mjs'
8
8
 
9
9
 
@@ -38,9 +38,9 @@ let settings = {
38
38
  let funNew = (ndata = {}) => {
39
39
  let o = dtmapping(ndata, keys(settings))
40
40
  o.id = `${now2strp()}-${genID()}`
41
- o.timeCreate = nowms2str()
42
- o.timeUpdate = o.timeCreate
43
- o.isActive = 'y'
41
+ // o.timeCreate = nowms2str()
42
+ // o.timeUpdate = o.timeCreate
43
+ // o.isActive = 'y'
44
44
  return o
45
45
  }
46
46
 
@@ -104,7 +104,7 @@ let funTest = () => {
104
104
  rs[3].from = 'teamB'
105
105
  rs[4].from = 'teamB'
106
106
  rs[4].isActive = 'n'
107
- rs[5].ruleGroupsIds = `id-for-L1權限群組`
107
+ rs[5].ruleGroupsIds = `id-for-權限群組1`
108
108
  rs[5].description = '測試系統管理員描述說明'
109
109
  rs[5].isAdmin = 'y' //admin
110
110
  console.log(`已產生: ${keyTable} 測試資料`, rs)
@@ -1 +1 @@
1
- {"ruleGroups":"t5bra2","targets":"OxwFDJ","users":"t7oXtY"}
1
+ {"ruleGroups":"rXJNLB","targets":"4GLDb2","users":"AG7IvW"}