-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.js
54 lines (47 loc) · 1.33 KB
/
types.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import _ from 'lodash'
import { XS_NS, XS_PREFIX } from './const'
import NAMESPACES from './wsdl/namespaces/index'
function bestTypeMatch (wsdl, type, data) {
}
export default function createTypes (wsdl) {
let [ nsCount, types ] = [ 1, {} ]
// add convert functions to builtins
let nsIdx = 0
_.forEach(NAMESPACES, (ns) => {
let typeIdx = 0
_.forEach(ns, (type) => {
wsdl.metadata.types[nsIdx][typeIdx] = _.cloneDeep(type)
typeIdx++
})
nsIdx++
})
// add extendedBy to keep track of inheritance
_.forEach(wsdl.metadata.types, (namespace, nsIdx) => {
_.forEach(namespace, (type, typeIdx) => {
if (type.base) {
let t = wsdl.getType(type.base)
if (t) {
t.extendedBy = t.extendedBy || []
t.extendedBy.push([nsIdx, typeIdx])
}
}
})
})
_.forEach(wsdl.metadata.namespaces, (namespace, nsIdx) => {
let prefix = `ns${nsCount}`
if (namespace.prefix) {
prefix = namespace.prefix
} else if (namespace.name === XS_NS) {
wsdl.metadata.namespaces[nsIdx].prefix = XS_PREFIX
prefix = XS_PREFIX
} else {
wsdl.metadata.namespaces[nsIdx].prefix = prefix
nsCount++
}
_.forEach(namespace.types, (typeName, typeIdx) => {
_.set(types, `["${prefix}"]["${typeName}"]`, (data) => {
})
})
})
return types
}