w-web-api 1.0.0

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 (78) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +54 -0
  4. package/.jsdoc +25 -0
  5. package/LICENSE +21 -0
  6. package/README.md +62 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +14 -0
  9. package/dist/w-web-api.umd.js +7 -0
  10. package/dist/w-web-api.umd.js.map +1 -0
  11. package/docs/WWebApi.html +551 -0
  12. package/docs/WWebApi.mjs.html +335 -0
  13. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  15. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  16. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  17. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  18. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  19. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  20. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  28. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  30. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  31. package/docs/index.html +81 -0
  32. package/docs/scripts/collapse.js +20 -0
  33. package/docs/scripts/linenumber.js +25 -0
  34. package/docs/scripts/nav.js +12 -0
  35. package/docs/scripts/polyfill.js +4 -0
  36. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  37. package/docs/scripts/prettify/lang-css.js +2 -0
  38. package/docs/scripts/prettify/prettify.js +28 -0
  39. package/docs/scripts/search.js +83 -0
  40. package/docs/styles/jsdoc.css +765 -0
  41. package/docs/styles/prettify.css +79 -0
  42. package/package.json +81 -0
  43. package/public/connecting.svg +10 -0
  44. package/public/deny.png +0 -0
  45. package/public/disconnect.png +0 -0
  46. package/public/index.html +23 -0
  47. package/public/logout.png +0 -0
  48. package/server/WWebApi.mjs +283 -0
  49. package/server/getSettings.mjs +17 -0
  50. package/server/mDb.mjs +76 -0
  51. package/server/mInitialTestData.mjs +40 -0
  52. package/server/mOrm.mjs +22 -0
  53. package/src/App.vue +91 -0
  54. package/src/components/Layout.vue +131 -0
  55. package/src/components/LayoutContent.vue +67 -0
  56. package/src/components/LayoutContentList.vue +573 -0
  57. package/src/components/MdPanel.vue +152 -0
  58. package/src/main.js +98 -0
  59. package/src/plugins/mDataSelectorSchema.mjs +30 -0
  60. package/src/plugins/mDataSupport.mjs +78 -0
  61. package/src/plugins/mShare.mjs +235 -0
  62. package/src/plugins/mUI.mjs +141 -0
  63. package/src/plugins/mVuetify.mjs +12 -0
  64. package/src/schema/gi.mjs +8 -0
  65. package/src/schema/index.mjs +16 -0
  66. package/src/schema/tables/apis.mjs +918 -0
  67. package/src/store/actions.mjs +1 -0
  68. package/src/store/getters.mjs +1 -0
  69. package/src/store/index.mjs +25 -0
  70. package/src/store/mutations.mjs +185 -0
  71. package/src/store/types.mjs +14 -0
  72. package/srv.mjs +33 -0
  73. package/tableTags.json +1 -0
  74. package/toolg/addVersion.mjs +4 -0
  75. package/toolg/cleanFolder.mjs +4 -0
  76. package/toolg/gDistRollup.mjs +34 -0
  77. package/toolg/modifyReadme.mjs +4 -0
  78. package/vue.config.js +15 -0
@@ -0,0 +1,573 @@
1
+ <template>
2
+ <div
3
+ style="height:100%;"
4
+ :changeApis="changeApis"
5
+ >
6
+
7
+ <div style="display:flex; height:100%;" v-if="hasApis">
8
+
9
+ <div style="min-width:400px; height:100%; _font-size:10pt; color:#444; background:#fff; overflow-y:auto;">
10
+
11
+ <WTree
12
+ :viewHeightMax="null"
13
+ :data="apisTree"
14
+ :iconHeight="lineHeightTree"
15
+ :defItemHeight="lineHeightTree"
16
+ :activable="true"
17
+ :activeItem="apiActive"
18
+ :fun-active="funActive"
19
+ :itemTextColorActive="'#000'"
20
+ :itemBackgroundColorActive ="'rgba(100,100,100,0.15)'"
21
+ >
22
+ <template v-slot:item="props">
23
+
24
+ <div
25
+ :style="`display:flex; align-items:center; min-height:${lineHeightTree}px;`"
26
+ v-if="props.data.type!=='node'"
27
+ >
28
+ {{props.data.key}}
29
+ </div>
30
+
31
+ <div
32
+ :style="`display:flex; align-items:center; min-height:${lineHeightTree}px; cursor:pointer;`"
33
+ @click="ckItem(getItemByKey(props.data.text))"
34
+ v-else
35
+ >
36
+
37
+ <div style="padding-right:5px;">
38
+ <div :style="`padding:0px 6px; font-size:0.7rem; border-radius:10px; border:1px solid #ddd; color:#fff; background:${getMethodColorByKey(props.data.text)};`">
39
+ {{getMethodByKey(props.data.text)}}
40
+ </div>
41
+ </div>
42
+
43
+ <div>
44
+ {{$s.gv(getItemByKey(props.data.text),'name')}}
45
+ </div>
46
+
47
+ </div>
48
+
49
+ </template>
50
+ </WTree>
51
+
52
+ </div>
53
+
54
+ <div style="height:100%; border-right:1px solid #ddd;"></div>
55
+
56
+ <div style="width:100%; height:100%; overflow-y:auto;" v-if="apiSelect">
57
+ <div style="padding:15px 20px 10px 10px;">
58
+
59
+ <div style="padding:5px;">
60
+
61
+ <div style="padding:10px; border-radius:5px; border:1px solid #ddd; background:#fff; display:flex; align-items:center;">
62
+
63
+ <div style="padding-right:5px;">
64
+ <div :style="`padding:0px 6px; font-size:0.7rem; border-radius:10px; border:1px solid #ddd; color:#fff; background:${getMethodColor(apiSelect)};`">
65
+ {{getMethod(apiSelect)}}
66
+ </div>
67
+ </div>
68
+
69
+ <div style="font-size:0.8rem;">
70
+ {{$s.gv(apiSelect,'url')}}
71
+ </div>
72
+
73
+ </div>
74
+
75
+ </div>
76
+
77
+ <div style="padding:10px;">
78
+
79
+ <div style="color:#485ed5;">
80
+ {{$s.gv(apiSelect,'name')}}
81
+ </div>
82
+
83
+ <div class="bk-title" style="">
84
+ {{$s.gv(apiSelect,'description')}}
85
+ </div>
86
+
87
+ </div>
88
+
89
+ <div style="padding:10px;">
90
+
91
+ <div class="bk" style="">
92
+
93
+ <div class="bk-title" style="">
94
+ {{kpTexts.tokens}}
95
+ </div>
96
+
97
+ <div class="bk-item" style="">
98
+ {{$s.gv(apiSelect,'tokens')}}
99
+ </div>
100
+
101
+ </div>
102
+
103
+ <div class="bk" style="">
104
+
105
+ <div class="bk-title" style="">
106
+ {{kpTexts.version}}
107
+ </div>
108
+
109
+ <div class="bk-item" style="">
110
+ {{$s.gv(apiSelect,'version')}}
111
+ </div>
112
+
113
+ </div>
114
+
115
+ <div class="bk" style="">
116
+
117
+ <div class="bk-title" style="">
118
+ {{kpTexts.levels}}
119
+ </div>
120
+
121
+ <div class="bk-item" style="">
122
+ {{$s.gv(apiSelect,'')}}
123
+ </div>
124
+
125
+ </div>
126
+
127
+ <div class="bk" style="">
128
+
129
+ <div class="bk-title" style="">
130
+ {{kpTexts.keywords}}
131
+ </div>
132
+
133
+ <div class="bk-item" style="">
134
+ {{$s.gv(apiSelect,'')}}
135
+ </div>
136
+
137
+ </div>
138
+
139
+ <div class="bk" style="">
140
+
141
+ <div class="bk-title" style="">
142
+ {{kpTexts.state}}
143
+ </div>
144
+
145
+ <div class="bk-item" style="">
146
+ {{$s.gv(apiSelect,'')}}
147
+ </div>
148
+
149
+ </div>
150
+
151
+ <div class="bk" style="">
152
+
153
+ <div class="bk-title" style="">
154
+ {{kpTexts.timeCreate}}
155
+ </div>
156
+
157
+ <div class="bk-item" style="">
158
+ {{getDay($s.gv(apiSelect,'timeCreate'))}}
159
+ </div>
160
+
161
+ </div>
162
+
163
+ <div class="bk" style="">
164
+
165
+ <div class="bk-title" style="">
166
+ {{kpTexts.timeUpdate}}
167
+ </div>
168
+
169
+ <div class="bk-item" style="">
170
+ {{getDay($s.gv(apiSelect,'timeUpdate'))}}
171
+ </div>
172
+
173
+ </div>
174
+
175
+ <div class="bk" style="">
176
+
177
+ <div class="bk-title" style="">
178
+ {{kpTexts.creator}}
179
+ </div>
180
+
181
+ <div class="bk-item" style="">
182
+ {{$s.gv(apiSelect,'creator')}}
183
+ </div>
184
+
185
+ </div>
186
+
187
+ <div class="bk" style="">
188
+
189
+ <div class="bk-title" style="">
190
+ {{kpTexts.dataSource}}
191
+ </div>
192
+
193
+ <div class="bk-item" style="">
194
+ {{$s.gv(apiSelect,'dataSource')}}
195
+ </div>
196
+
197
+ </div>
198
+
199
+ <div class="bk" style="">
200
+
201
+ <div class="bk-title" style="">
202
+ {{kpTexts.isActive}}
203
+ </div>
204
+
205
+ <div class="bk-item" style="">
206
+ {{$s.gv(apiSelect,'isActive')}}
207
+ </div>
208
+
209
+ </div>
210
+
211
+ </div>
212
+
213
+ <div style="padding:10px;">
214
+
215
+ <div class="bk-title" style="">
216
+ {{kpTexts.mdInputParams}}
217
+ </div>
218
+
219
+ <div class="bk-item" style="padding:10px;">
220
+ <MdPanel
221
+ :md="$s.gv(apiSelect,'mdInputParams')"
222
+ ></MdPanel>
223
+ </div>
224
+
225
+ </div>
226
+
227
+ <div style="padding:10px;">
228
+
229
+ <div class="bk-title" style="">
230
+ {{kpTexts.inputExample}}
231
+ </div>
232
+
233
+ <div class="bk-item" style="padding:10px;">
234
+ {{$s.gv(apiSelect,'inputExample')}}
235
+ </div>
236
+
237
+ </div>
238
+
239
+ <div style="padding:10px;">
240
+
241
+ <div class="bk-title" style="">
242
+ {{kpTexts.mdOutputParams}}
243
+ </div>
244
+
245
+ <div class="bk-item" style="padding:10px;">
246
+ <MdPanel
247
+ :md="$s.gv(apiSelect,'mdOutputParams')"
248
+ ></MdPanel>
249
+ </div>
250
+
251
+ </div>
252
+
253
+ <div style="padding:10px;">
254
+
255
+ <div class="bk-title" style="">
256
+ {{kpTexts.outputExample}}
257
+ </div>
258
+
259
+ <div style="padding-top:10px;">
260
+
261
+ <div style="padding-left:10px; margin-bottom:-1px;">
262
+ <!-- 因上下皆有border, 故需負margin-bottom來吃掉重複border -->
263
+ <WGroupRadio
264
+ :items="optputMenuItems"
265
+ :value="optputMenuItemSelect"
266
+ @input="changeOptputMenuItemSelect"
267
+ :group="true"
268
+ :group-border-radius-style="{top:true}"
269
+ :group-shift="7"
270
+ :border-radius="20"
271
+ :border-color="'#ddd'"
272
+ :border-color-hover="'#dadada'"
273
+ :border-color-active="'orange lighten-2'"
274
+ :margin-style="{}"
275
+ ></WGroupRadio>
276
+ </div>
277
+
278
+ <div style="border:1px solid #ddd; background:#fff">
279
+
280
+ <div style="" v-if="optputMenuItemSelectId==='tree'">
281
+ <WJsonView
282
+ style="width:100%;"
283
+ :viewHeightMax="null"
284
+ :data="getOutputJsonObj(apiSelect)"
285
+ ></WJsonView>
286
+ </div>
287
+
288
+ <div style="padding:10px; color:#555; font-size:0.85rem;" v-if="optputMenuItemSelectId==='raw'">
289
+ <pre>{{getOutputJson(apiSelect)}}</pre>
290
+ </div>
291
+
292
+ </div>
293
+
294
+ </div>
295
+
296
+ </div>
297
+
298
+ </div>
299
+ </div>
300
+
301
+ <div
302
+ style="padding:20px; font-size:0.9rem;"
303
+ v-else
304
+ >
305
+ {{kpTexts.noSelectApi}}
306
+ </div>
307
+
308
+ </div>
309
+
310
+ <div
311
+ style="padding:20px; font-size:0.9rem;"
312
+ v-else
313
+ >
314
+ {{kpTexts.waitingData}}
315
+ </div>
316
+
317
+ </div>
318
+ </template>
319
+
320
+ <script>
321
+ import get from 'lodash/get'
322
+ import set from 'lodash/set'
323
+ // import map from 'lodash/map'
324
+ import each from 'lodash/each'
325
+ import size from 'lodash/size'
326
+ // import join from 'lodash/join'
327
+ import trim from 'lodash/trim'
328
+ import find from 'lodash/find'
329
+ import cloneDeep from 'lodash/cloneDeep'
330
+ // import isestr from 'wsemi/src/isestr.mjs'
331
+ // import isnum from 'wsemi/src/isnum.mjs'
332
+ // import isarr from 'wsemi/src/isarr.mjs'
333
+ import isobj from 'wsemi/src/isobj.mjs'
334
+ import iseobj from 'wsemi/src/iseobj.mjs'
335
+ import j2o from 'wsemi/src/j2o.mjs'
336
+ // import cdbl from 'wsemi/src/cdbl.mjs'
337
+ // import str2md5 from 'wsemi/src/str2md5.mjs'
338
+ // import sep from 'wsemi/src/sep.mjs'
339
+ import timemsTZ2day from 'wsemi/src/timemsTZ2day.mjs'
340
+ import convertToTree from 'wsemi/src/convertToTree.mjs'
341
+ import WGroupRadio from 'w-component-vue/src/components/WGroupRadio.vue'
342
+ import WTree from 'w-component-vue/src/components/WTree.vue'
343
+ import WJsonView from 'w-component-vue/src/components/WJsonView.vue'
344
+ import MdPanel from './MdPanel.vue'
345
+
346
+
347
+ export default {
348
+ components: {
349
+ WGroupRadio,
350
+ WTree,
351
+ WJsonView,
352
+ MdPanel,
353
+ },
354
+ props: {
355
+ },
356
+ data: function() {
357
+ return {
358
+
359
+ lineHeightTree: 38,
360
+
361
+ apisTree: [],
362
+ kpApisTree: {},
363
+ apiActive: null,
364
+ apiSelect: null,
365
+
366
+ kpColorMethod: {
367
+ GET: '#7c2',
368
+ POST: '#68f',
369
+ PUT: '#f82',
370
+ DEL: '#f26',
371
+ },
372
+
373
+ optputMenuItemSelectId: 'tree',
374
+
375
+ }
376
+ },
377
+ computed: {
378
+
379
+ kpTexts: function() {
380
+ return this.$ui.getKpLang()
381
+ },
382
+
383
+ apis: function() {
384
+ return get(this, '$store.state.apis')
385
+ },
386
+
387
+ changeApis: function() {
388
+ let vo = this
389
+ vo.genTree(vo.apis)
390
+ return ''
391
+ },
392
+
393
+ hasApis: function() {
394
+ return size(this.apisTree) > 0
395
+ },
396
+
397
+ optputMenuItems: function() {
398
+ let vo = this
399
+ let ms = [
400
+ {
401
+ id: 'tree',
402
+ text: vo.kpTexts.outputMenuTree,
403
+ icon: 'mdi-vanity-light',
404
+ },
405
+ {
406
+ id: 'raw',
407
+ text: vo.kpTexts.outputMenuRaw,
408
+ icon: 'mdi-lan',
409
+ },
410
+ ]
411
+ return ms
412
+ },
413
+
414
+ optputMenuItemSelect: function() {
415
+ let vo = this
416
+ let r = find(vo.optputMenuItems, { id: vo.optputMenuItemSelectId })
417
+ // console.log(r)
418
+ return r
419
+ },
420
+
421
+ },
422
+ methods: {
423
+
424
+ genTree: function () {
425
+ let vo = this
426
+
427
+ //default
428
+ vo.apisTree = []
429
+ vo.kpApisTree = {}
430
+
431
+ //cloneDeep
432
+ let apis = cloneDeep(vo.apis)
433
+ // console.log('apis', cloneDeep(apis))
434
+
435
+ //tr
436
+ let tr = {}
437
+ let kpTree = {}
438
+ each(apis, (v) => {
439
+
440
+ //id, levels
441
+ let id = v.id
442
+ let levels = `${v.levels}.${v.name}`
443
+
444
+ //save
445
+ kpTree[id] = v
446
+
447
+ //check
448
+ if (!isobj(get(tr, levels))) {
449
+ set(tr, levels, id)
450
+ }
451
+
452
+ })
453
+ // console.log('tr', cloneDeep(tr))
454
+ // console.log('kpTree', cloneDeep(kpTree))
455
+
456
+ //convertToTree, 由預處理tree物件轉成tree物件
457
+ let tree = convertToTree(tr, { bindRoot: '全部' })
458
+ // console.log('tree', cloneDeep(tree))
459
+
460
+ //apiSelect, 預先選定api項目, 非tree選單active物件, 因id由convertToTree轉換提供, 故不能直接算得active選單物件id
461
+ let apiSelect = get(apis, 0, null)
462
+ // console.log('apiSelect', cloneDeep(apiSelect))
463
+
464
+ //save
465
+ vo.apiSelect = apiSelect
466
+ vo.apisTree = tree
467
+ vo.kpApisTree = kpTree
468
+
469
+ },
470
+
471
+ getItemByKey: function(key) {
472
+ let vo = this
473
+ // let k = `kpApisTree.${key}`
474
+ // console.log('getItemByKey k', k)
475
+ let r = vo.kpApisTree[key]
476
+ // console.log('getItemByKey r', r, vo.kpApisTree)
477
+ return r
478
+ },
479
+
480
+ getMethod: function(item) {
481
+ // let vo = this
482
+ let method = get(item, 'method', '').toUpperCase()
483
+ return method
484
+ },
485
+
486
+ getMethodByKey: function(key) {
487
+ let vo = this
488
+ let item = vo.getItemByKey(key)
489
+ let method = get(item, 'method', '').toUpperCase()
490
+ return method
491
+ },
492
+
493
+ getMethodColor: function(item) {
494
+ let vo = this
495
+ let method = vo.getMethod(item)
496
+ let color = get(vo.kpColorMethod, method, '#888')
497
+ return color
498
+ },
499
+
500
+ getMethodColorByKey: function(key) {
501
+ let vo = this
502
+ let method = vo.getMethodByKey(key)
503
+ let color = get(vo.kpColorMethod, method, '#888')
504
+ return color
505
+ },
506
+
507
+ getDay: function(t) {
508
+ return timemsTZ2day(t)
509
+ },
510
+
511
+ getOutputJson: function(item) {
512
+ // let vo = this
513
+ let j = get(item, 'outputExample', '')
514
+ j = trim(j)
515
+ return j
516
+ },
517
+
518
+ getOutputJsonObj: function(item) {
519
+ // let vo = this
520
+ let j = this.getOutputJson(item)
521
+ let o = j2o(j)
522
+ return o
523
+ },
524
+
525
+ funActive: function(msg) {
526
+ let vo = this
527
+ let b = !Array.isArray(msg.item.children) //children非陣列代表沒有所屬節點
528
+ if (b) {
529
+ if (!iseobj(vo.apiActive)) { //偵測若沒有apiActive才初始化預先選擇之api項目, 非api完整資訊
530
+ let id = msg.item.id
531
+ vo.apiActive = { id }
532
+ // console.log('!iseobj(vo.apiActive)', vo.apiActive)
533
+ }
534
+ }
535
+ return b
536
+ },
537
+
538
+ changeOptputMenuItemSelect: function(msg) {
539
+ // console.log('changeOptputMenuItemSelect', msg)
540
+ let vo = this
541
+ vo.optputMenuItemSelectId = msg.id
542
+ },
543
+
544
+ ckItem: function(item) {
545
+ // console.log('ckItem', item)
546
+ let vo = this
547
+ vo.apiSelect = cloneDeep(item)
548
+ },
549
+
550
+ }
551
+ }
552
+ </script>
553
+
554
+ <style scoped>
555
+ .bk {
556
+ display:inline-block;
557
+ width:200px;
558
+ padding:0px 10px 10px 0px;
559
+ vertical-align:top;
560
+ }
561
+ .bk-title {
562
+ font-size:0.8rem;
563
+ color:#888;
564
+ }
565
+ .bk-item {
566
+ padding:3px 5px;
567
+ font-size:0.9rem;
568
+ line-height:0.9rem;
569
+ border-radius:5px;
570
+ border:1px solid #ddd;
571
+ background:#fff;
572
+ }
573
+ </style>