@symbo.ls/fetch 2.4.1 → 2.6.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.
- package/index.js +22 -9
- package/package.json +5 -3
package/index.js
CHANGED
|
@@ -1,45 +1,58 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { client, fetch } from '@symbo.ls/based'
|
|
4
|
+
import { deepMerge } from '@domql/utils'
|
|
5
|
+
|
|
6
|
+
import TMP_DATA from '@symbo.ls/temp-db'
|
|
7
|
+
import CONFIG_DEFAULT from '@symbo.ls/config-default'
|
|
4
8
|
|
|
5
9
|
export const fetchIcon = async (el, s, { icon }) => {
|
|
6
10
|
await client.observe({
|
|
7
11
|
$id: icon,
|
|
8
12
|
$all: true
|
|
9
|
-
}, (data) => {
|
|
13
|
+
}, async (data) => {
|
|
14
|
+
console.log(data)
|
|
15
|
+
await client.set({
|
|
16
|
+
$id: s.projectId,
|
|
17
|
+
icon
|
|
18
|
+
}, d => console.log('d', d))
|
|
19
|
+
console.log('data', data)
|
|
10
20
|
s.update({ icon: data })
|
|
11
21
|
})
|
|
12
22
|
}
|
|
13
23
|
|
|
14
|
-
export const fetchProject = (el, s, { userName, projectId }) => {
|
|
24
|
+
export const fetchProject = (el, s, { userName, projectId, ...options }) => {
|
|
15
25
|
fetch({
|
|
16
26
|
$id: projectId,
|
|
17
27
|
$all: true
|
|
18
28
|
}, async data => {
|
|
19
|
-
console.log(data)
|
|
20
29
|
const { key, name, state, icon, system } = data
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
const { SYSTEM, STATE } = TMP_DATA[key]
|
|
32
|
+
deepMerge(s.SYSTEM, system || SYSTEM || CONFIG_DEFAULT)
|
|
33
|
+
deepMerge(s.STATE, state || STATE || {})
|
|
34
|
+
console.log(data)
|
|
35
|
+
console.log(s.SYSTEM, s.STATE)
|
|
24
36
|
|
|
25
37
|
s.update({
|
|
26
38
|
appKey: key,
|
|
27
39
|
projectName: name,
|
|
28
40
|
userName,
|
|
29
41
|
projectId
|
|
30
|
-
})
|
|
42
|
+
}, options)
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
console.log(icon)
|
|
45
|
+
await fetchIcon(el, s, { icon })
|
|
33
46
|
})
|
|
34
47
|
}
|
|
35
48
|
|
|
36
|
-
export const fetchUser = (el, s) => {
|
|
49
|
+
export const fetchUser = (el, s, options) => {
|
|
37
50
|
fetch({ $id: s.userId, name: true, projects: true }, data => {
|
|
38
51
|
const { projects } = data
|
|
39
52
|
const userName = data.name
|
|
40
53
|
if (projects) {
|
|
41
54
|
const projectId = projects[0]
|
|
42
|
-
fetchProject(el, s, { userName, projectId })
|
|
55
|
+
fetchProject(el, s, { userName, projectId, ...options })
|
|
43
56
|
}
|
|
44
57
|
})
|
|
45
58
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/fetch",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@symbo.ls/based": "latest"
|
|
6
|
+
"@symbo.ls/based": "latest",
|
|
7
|
+
"@symbo.ls/config-default": "latest",
|
|
8
|
+
"@symbo.ls/temp-db": "latest"
|
|
7
9
|
},
|
|
8
|
-
"
|
|
10
|
+
"gitHead": "41981d1b4f550992e08104002a6ca83398c03084"
|
|
9
11
|
}
|