@symbo.ls/fetch 2.4.2 → 2.6.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.
Files changed (2) hide show
  1. package/index.js +17 -8
  2. package/package.json +5 -3
package/index.js CHANGED
@@ -1,44 +1,53 @@
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
+ await client.set({
15
+ $id: s.projectId,
16
+ icon
17
+ }, d => console.log('d', d))
10
18
  s.update({ icon: data })
11
19
  })
12
20
  }
13
21
 
14
- export const fetchProject = (el, s, { userName, projectId }) => {
22
+ export const fetchProject = (el, s, { userName, projectId, ...options }) => {
15
23
  fetch({
16
24
  $id: projectId,
17
25
  $all: true
18
26
  }, async data => {
19
27
  const { key, name, state, icon, system } = data
20
28
 
21
- if (system) s.SYSTEM = { ...system }
22
- if (state) s.STATE = { ...state }
29
+ const { SYSTEM, STATE } = TMP_DATA[key]
30
+ deepMerge(s.SYSTEM, system || SYSTEM || CONFIG_DEFAULT)
31
+ deepMerge(s.STATE, state || STATE || {})
23
32
 
24
33
  s.update({
25
34
  appKey: key,
26
35
  projectName: name,
27
36
  userName,
28
37
  projectId
29
- })
38
+ }, options)
30
39
 
31
- fetchIcon(el, s, { icon })
40
+ await fetchIcon(el, s, { icon })
32
41
  })
33
42
  }
34
43
 
35
- export const fetchUser = (el, s) => {
44
+ export const fetchUser = (el, s, options) => {
36
45
  fetch({ $id: s.userId, name: true, projects: true }, data => {
37
46
  const { projects } = data
38
47
  const userName = data.name
39
48
  if (projects) {
40
49
  const projectId = projects[0]
41
- fetchProject(el, s, { userName, projectId })
50
+ fetchProject(el, s, { userName, projectId, ...options })
42
51
  }
43
52
  })
44
53
  }
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@symbo.ls/fetch",
3
- "version": "2.4.2",
3
+ "version": "2.6.1",
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
- "devDependencies": {}
10
+ "gitHead": "1e2a78210100223b80558d76fd6db7d9fc022a1b"
9
11
  }