@open-xchange/soap-client 0.0.11 → 0.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/soap-client",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "SOAP client for OX App Suite",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,14 +20,18 @@
20
20
 
21
21
  import { createClientAsync, logSoapError } from '../../soap.js'
22
22
 
23
- const OXContextService = createClientAsync('OXContextService')
23
+ let OXContextService
24
+ function getClient () {
25
+ if (!OXContextService) OXContextService = createClientAsync('OXContextService')
26
+ return OXContextService
27
+ }
24
28
 
25
29
  /**
26
30
  * This function retrieves the default context from the OXContextService.
27
31
  * @returns {Promise<Object>} The first result from the listAsync method call.
28
32
  */
29
33
  export async function getDefault () {
30
- return (await OXContextService).listAsync({ search_pattern: 'defaultcontext' })[0]
34
+ return (await getClient()).listAsync({ search_pattern: 'defaultcontext' })[0]
31
35
  }
32
36
 
33
37
  /**
@@ -36,7 +40,7 @@ export async function getDefault () {
36
40
  * @param {number} id The ID of the context to remove.
37
41
  */
38
42
  export async function remove (id) {
39
- return (await OXContextService).deleteAsync({ ctx: { id } })
43
+ return (await getClient()).deleteAsync({ ctx: { id } })
40
44
  }
41
45
 
42
46
  /**
@@ -59,7 +63,7 @@ export async function remove (id) {
59
63
  * @returns {Promise<Object>} The created context.
60
64
  */
61
65
  export async function create (ctx = {}, adminUser = {}, accessCombinationName = 'all') {
62
- return (await OXContextService)
66
+ return (await getClient())
63
67
  .createAsync({
64
68
  ctx,
65
69
  admin_user: Object.assign({
@@ -91,7 +95,7 @@ export async function create (ctx = {}, adminUser = {}, accessCombinationName =
91
95
  // eslint-disable-next-line camelcase
92
96
  export async function changeModuleAccessByName (id, access_combination_name) {
93
97
  // eslint-disable-next-line camelcase
94
- return (await OXContextService).changeModuleAccessByNameAsync({ ctx: { id }, access_combination_name })
98
+ return (await getClient()).changeModuleAccessByNameAsync({ ctx: { id }, access_combination_name })
95
99
  }
96
100
 
97
101
  /**
@@ -105,7 +109,7 @@ export async function changeCapabilities (id, capsToAdd, capsToRemove) {
105
109
  const data = {}
106
110
  if (capsToAdd) data.capsToAdd = capsToAdd
107
111
  if (capsToRemove) data.capsToRemove = capsToRemove
108
- return (await OXContextService).changeCapabilitiesAsync({ ctx: { id }, ...data })
112
+ return (await getClient()).changeCapabilitiesAsync({ ctx: { id }, ...data })
109
113
  }
110
114
 
111
115
  /**
@@ -114,7 +118,7 @@ export async function changeCapabilities (id, capsToAdd, capsToRemove) {
114
118
  * @returns {Promise<Object>} The module access of the specified context.
115
119
  */
116
120
  export async function getModuleAccess (id) {
117
- return (await OXContextService).getModuleAccessAsync({ ctx: { id } })
121
+ return (await getClient()).getModuleAccessAsync({ ctx: { id } })
118
122
  }
119
123
  /**
120
124
  * This function changes the module access of the specified context.
@@ -124,7 +128,7 @@ export async function getModuleAccess (id) {
124
128
  */
125
129
  export async function changeModuleAccess (id, moduleAccess) {
126
130
  const currentAccess = await getModuleAccess(id)
127
- return (await OXContextService).changeModuleAccessAsync({ ctx: { id }, access: { ...currentAccess, ...moduleAccess } })
131
+ return (await getClient()).changeModuleAccessAsync({ ctx: { id }, access: { ...currentAccess, ...moduleAccess } })
128
132
  }
129
133
 
130
134
  /**
@@ -135,7 +139,7 @@ export async function changeModuleAccess (id, moduleAccess) {
135
139
  * @returns {Promise<Array<Object>>} The list of contexts that match the search pattern.
136
140
  */
137
141
  export async function list (searchPattern, { excludeDisabled } = { excludeDisabled: true }) {
138
- return (await OXContextService).listAsync({ search_pattern: searchPattern, exclude_disabled: excludeDisabled }).catch(e => {
142
+ return (await getClient()).listAsync({ search_pattern: searchPattern, exclude_disabled: excludeDisabled }).catch(e => {
139
143
  logSoapError(e)
140
144
  return []
141
145
  })
@@ -147,7 +151,7 @@ export async function list (searchPattern, { excludeDisabled } = { excludeDisabl
147
151
  * @returns {Promise<Object>} The context with the specified ID.
148
152
  */
149
153
  export async function get (id) {
150
- return (await OXContextService).getDataAsync({ ctx: { id } })
154
+ return (await getClient()).getDataAsync({ ctx: { id } })
151
155
  }
152
156
 
153
157
  /**
@@ -156,5 +160,5 @@ export async function get (id) {
156
160
  * @returns {Promise<void>}
157
161
  */
158
162
  export async function change (ctx) {
159
- return (await OXContextService).changeAsync({ ctx })
163
+ return (await getClient()).changeAsync({ ctx })
160
164
  }
@@ -20,7 +20,11 @@
20
20
 
21
21
  import { createClientAsync, logSoapError } from '../../soap.js'
22
22
 
23
- const OXUserService = createClientAsync('OXUserService')
23
+ let OXUserService
24
+ function getClient () {
25
+ if (!OXUserService) OXUserService = createClientAsync('OXUserService')
26
+ return OXUserService
27
+ }
24
28
 
25
29
  /**
26
30
  * This function removes the user with the specified context and user ID.
@@ -29,7 +33,7 @@ const OXUserService = createClientAsync('OXUserService')
29
33
  * @returns {Promise<Boolean>} Returns true if it could remove the user and false if it could not
30
34
  */
31
35
  export async function remove (context, userId) {
32
- return (await OXUserService).deleteAsync({
36
+ return (await getClient()).deleteAsync({
33
37
  ctx: { id: context.id },
34
38
  user: { id: userId },
35
39
  auth: context.admin
@@ -43,7 +47,7 @@ export async function remove (context, userId) {
43
47
  * @returns {Promise<Object>} The created user.
44
48
  */
45
49
  export async function create (context, usrdata) {
46
- return (await OXUserService).createAsync({
50
+ return (await getClient()).createAsync({
47
51
  ctx: { id: context.id },
48
52
  usrdata,
49
53
  auth: context.admin
@@ -57,7 +61,7 @@ export async function create (context, usrdata) {
57
61
  * @returns {Promise<void>}
58
62
  */
59
63
  export async function change (context, usrdata) {
60
- return (await OXUserService).changeAsync({
64
+ return (await getClient()).changeAsync({
61
65
  ctx: { id: context.id },
62
66
  usrdata,
63
67
  auth: context.admin
@@ -65,7 +69,7 @@ export async function change (context, usrdata) {
65
69
  }
66
70
 
67
71
  export async function changeByModuleAccess (context, userId, currentAccess, moduleAccess) {
68
- return (await OXUserService).changeByModuleAccessAsync({
72
+ return (await getClient()).changeByModuleAccessAsync({
69
73
  ctx: { id: context.id },
70
74
  moduleAccess: Object.assign({}, currentAccess, moduleAccess),
71
75
  user: { id: userId },
@@ -74,7 +78,7 @@ export async function changeByModuleAccess (context, userId, currentAccess, modu
74
78
  }
75
79
 
76
80
  export async function changeByModuleAccessName (context, userId, accessCombinationName) {
77
- return (await OXUserService).changeByModuleAccessNameAsync({
81
+ return (await getClient()).changeByModuleAccessNameAsync({
78
82
  ctx: { id: context.id },
79
83
  access_combination_name: accessCombinationName,
80
84
  user: { id: userId },
@@ -83,7 +87,7 @@ export async function changeByModuleAccessName (context, userId, accessCombinati
83
87
  }
84
88
 
85
89
  export async function getModuleAccess (context, userId) {
86
- return (await OXUserService).getModuleAccessAsync({
90
+ return (await getClient()).getModuleAccessAsync({
87
91
  ctx: { id: context.id },
88
92
  user: { id: userId },
89
93
  auth: context.admin
@@ -100,11 +104,11 @@ export async function changeCapabilities (context, userId, capsToAdd, capsToRemo
100
104
  }
101
105
  if (capsToAdd) data.capsToAdd = capsToAdd
102
106
  if (capsToRemove) data.capsToRemove = capsToRemove
103
- return (await OXUserService).changeCapabilitiesAsync(data)
107
+ return (await getClient()).changeCapabilitiesAsync(data)
104
108
  }
105
109
 
106
110
  export async function exists (context, userId) {
107
- return (await OXUserService).existsAsync({
111
+ return (await getClient()).existsAsync({
108
112
  ctx: { id: context.id },
109
113
  user: { id: userId },
110
114
  auth: context.admin
@@ -112,7 +116,7 @@ export async function exists (context, userId) {
112
116
  }
113
117
 
114
118
  export async function list (context, searchPattern, includeGuests = false) {
115
- return (await OXUserService).listAsync({
119
+ return (await getClient()).listAsync({
116
120
  ctx: { id: context.id },
117
121
  search_pattern: searchPattern,
118
122
  include_guests: includeGuests,
@@ -121,7 +125,7 @@ export async function list (context, searchPattern, includeGuests = false) {
121
125
  }
122
126
 
123
127
  export async function listAll (context, includeGuests = false, excludeUsers = []) {
124
- return (await OXUserService).listAsync({
128
+ return (await getClient()).listAsync({
125
129
  ctx: { id: context.id },
126
130
  include_guests: includeGuests,
127
131
  exclude_users: excludeUsers,
@@ -20,12 +20,16 @@
20
20
 
21
21
  import { createClientAsync } from '../../soap.js'
22
22
 
23
- const OXaaSService = createClientAsync('OXaaSService').then(client => client)
23
+ let OXaaSService
24
+ function getClient () {
25
+ if (!OXaaSService) OXaaSService = createClientAsync('OXaaSService')
26
+ return OXaaSService
27
+ }
24
28
 
25
29
  export async function setMailQuota (data) {
26
- return (await OXaaSService).setMailQuotaAsync(data)
30
+ return (await getClient()).setMailQuotaAsync(data)
27
31
  }
28
32
 
29
33
  export async function createSharedDomain (data) {
30
- return (await OXaaSService).createSharedDomain(data)
34
+ return (await getClient()).createSharedDomain(data)
31
35
  }
@@ -20,36 +20,40 @@
20
20
 
21
21
  import { createClientAsync, logSoapError } from '../../soap.js'
22
22
 
23
- const OXResellerContextService = createClientAsync('OXResellerContextService')
23
+ let OXResellerContextService
24
+ function getClient () {
25
+ if (!OXResellerContextService) OXResellerContextService = createClientAsync('OXResellerContextService')
26
+ return OXResellerContextService
27
+ }
24
28
 
25
29
  export async function create (data) {
26
- return (await OXResellerContextService).createAsync(data)
30
+ return (await getClient()).createAsync(data)
27
31
  }
28
32
 
29
33
  export async function remove (contextId) {
30
- return (await OXResellerContextService).deleteAsync({
34
+ return (await getClient()).deleteAsync({
31
35
  ctx: { id: contextId }
32
36
  }).catch(logSoapError)
33
37
  }
34
38
 
35
39
  export async function change (ctx) {
36
- return (await OXResellerContextService).changeAsync({ ctx })
40
+ return (await getClient()).changeAsync({ ctx })
37
41
  }
38
42
 
39
43
  export async function get (id) {
40
- return (await OXResellerContextService).getDataAsync({ ctx: { id } })
44
+ return (await getClient()).getDataAsync({ ctx: { id } })
41
45
  }
42
46
 
43
47
  export async function getModuleAccess (id) {
44
- return (await OXResellerContextService).getModuleAccessAsync({ ctx: id })
48
+ return (await getClient()).getModuleAccessAsync({ ctx: id })
45
49
  }
46
50
 
47
51
  export async function changeModuleAccess (id, access) {
48
52
  const currentAccess = await getModuleAccess(id)
49
53
 
50
- return (await OXResellerContextService).changeModuleAccessAsync({ ctx: { id }, access: { ...currentAccess, ...access } })
54
+ return (await getClient()).changeModuleAccessAsync({ ctx: { id }, access: { ...currentAccess, ...access } })
51
55
  }
52
56
 
53
57
  export async function listAll (data) {
54
- return (await OXResellerContextService).listAllAsync(data)
58
+ return (await getClient()).listAllAsync(data)
55
59
  }
@@ -20,10 +20,14 @@
20
20
 
21
21
  import { createClientAsync, logSoapError } from '../../soap.js'
22
22
 
23
- const OXResellerUserService = createClientAsync('OXResellerUserService').then(client => client)
23
+ let OXResellerUserService
24
+ function getClient () {
25
+ if (!OXResellerUserService) OXResellerUserService = createClientAsync('OXResellerUserService')
26
+ return OXResellerUserService
27
+ }
24
28
 
25
29
  export async function remove (contextId, userId) {
26
- return (await OXResellerUserService).deleteAsync({
30
+ return (await getClient()).deleteAsync({
27
31
  ctx: { id: contextId },
28
32
  user: { id: userId }
29
33
  }).catch(logSoapError)
@@ -36,7 +40,7 @@ export async function remove (contextId, userId) {
36
40
  * @returns {Promise<void>}
37
41
  */
38
42
  export async function change (context, usrdata) {
39
- return (await OXResellerUserService).changeAsync({
43
+ return (await getClient()).changeAsync({
40
44
  ctx: { id: context.id },
41
45
  usrdata,
42
46
  auth: { login: context.admin.name, password: context.admin.password }
@@ -44,11 +48,11 @@ export async function change (context, usrdata) {
44
48
  }
45
49
 
46
50
  export async function get (data) {
47
- return (await OXResellerUserService).getDataAsync(data)
51
+ return (await getClient()).getDataAsync(data)
48
52
  }
49
53
 
50
54
  export async function getModuleAccess (context, userId) {
51
- return (await OXResellerUserService).getModuleAccessAsync({
55
+ return (await getClient()).getModuleAccessAsync({
52
56
  ctx: { id: context.id },
53
57
  user: { id: userId },
54
58
  auth: { login: context.admin.name, password: context.admin.password }
@@ -58,7 +62,7 @@ export async function getModuleAccess (context, userId) {
58
62
  }
59
63
 
60
64
  export async function changeByModuleAccess (context, userId, currentAccess, moduleAccess) {
61
- return (await OXResellerUserService).changeByModuleAccessAsync({
65
+ return (await getClient()).changeByModuleAccessAsync({
62
66
  ctx: { id: context.id },
63
67
  moduleAccess: Object.assign({}, currentAccess, moduleAccess),
64
68
  user: { id: userId },
@@ -67,7 +71,7 @@ export async function changeByModuleAccess (context, userId, currentAccess, modu
67
71
  }
68
72
 
69
73
  export async function changeByModuleAccessName (context, userId, accessCombinationName) {
70
- return (await OXResellerUserService).changeByModuleAccessNameAsync({
74
+ return (await getClient()).changeByModuleAccessNameAsync({
71
75
  ctx: { id: context.id },
72
76
  access_combination_name: accessCombinationName,
73
77
  user: { id: userId },
@@ -76,7 +80,7 @@ export async function changeByModuleAccessName (context, userId, accessCombinati
76
80
  }
77
81
 
78
82
  export async function createByModuleAccessName (context, usrdata) {
79
- return (await OXResellerUserService).createByModuleAccessNameAsync({
83
+ return (await getClient()).createByModuleAccessNameAsync({
80
84
  ctx: { id: context.id },
81
85
  usrdata,
82
86
  access_combination_name: 'all',
@@ -85,5 +89,5 @@ export async function createByModuleAccessName (context, usrdata) {
85
89
  }
86
90
 
87
91
  export async function listAll (data) {
88
- return await (await OXResellerUserService).listAllAsync(data)
92
+ return await (await getClient()).listAllAsync(data)
89
93
  }
@@ -1,6 +1,10 @@
1
1
  import { createClientAsync } from '../soap.js'
2
2
 
3
- const OXSecondaryAccountService = createClientAsync('OXSecondaryAccountService')
3
+ let OXSecondaryAccountService
4
+ function getClient () {
5
+ if (!OXSecondaryAccountService) OXSecondaryAccountService = createClientAsync('OXSecondaryAccountService')
6
+ return OXSecondaryAccountService
7
+ }
4
8
 
5
9
  /**
6
10
  * Creates a secondary account using the OX Secondary Account Service
@@ -13,7 +17,7 @@ const OXSecondaryAccountService = createClientAsync('OXSecondaryAccountService')
13
17
  * @throws {Error} If the account creation fails
14
18
  */
15
19
  export async function create (accountData, context, users = [], groups = []) {
16
- return (await OXSecondaryAccountService).createAsync({
20
+ return (await getClient()).createAsync({
17
21
  accountDataOnCreate: accountData,
18
22
  context: { id: context.id },
19
23
  users: users || [],
@@ -22,13 +26,13 @@ export async function create (accountData, context, users = [], groups = []) {
22
26
  }
23
27
 
24
28
  export async function list (context) {
25
- return (await OXSecondaryAccountService).listAsync({
29
+ return (await getClient()).listAsync({
26
30
  context: { id: context.id },
27
31
  auth: context.admin
28
32
  })
29
33
  }
30
34
  export async function remove (primaryAddress, context, users, groups) {
31
- return (await OXSecondaryAccountService).deleteAsync({
35
+ return (await getClient()).deleteAsync({
32
36
  primaryAddress,
33
37
  context: { id: context.id },
34
38
  users,
@@ -37,7 +41,7 @@ export async function remove (primaryAddress, context, users, groups) {
37
41
  }
38
42
 
39
43
  export async function update (primaryAddress, accountData, context, users, groups) {
40
- return (await OXSecondaryAccountService).updateAsync({
44
+ return (await getClient()).updateAsync({
41
45
  primaryAddress,
42
46
  accountDataUpdate: accountData,
43
47
  context: { id: context.id },
@@ -20,7 +20,11 @@
20
20
 
21
21
  import { createClientAsync } from '../soap.js'
22
22
 
23
- const OXSharedAccountService = createClientAsync('OXSharedAccountService')
23
+ let OXSharedAccountService
24
+ function getClient () {
25
+ if (!OXSharedAccountService) OXSharedAccountService = createClientAsync('OXSharedAccountService')
26
+ return OXSharedAccountService
27
+ }
24
28
 
25
29
  /**
26
30
  * Creates a shared account using the OX Shared Account Service
@@ -31,7 +35,7 @@ const OXSharedAccountService = createClientAsync('OXSharedAccountService')
31
35
  * @throws {Error} If the shared account creation fails
32
36
  */
33
37
  export async function create (context, sharedAccountData) {
34
- return (await OXSharedAccountService).createAsync({
38
+ return (await getClient()).createAsync({
35
39
  ctx: { id: context.id },
36
40
  sharedAccountData, // display_name, given_name, imapServer, language, mailenabled, name, sur_name, primaryEmail, email1, smtpServer, timezone, password
37
41
  auth: context.admin
@@ -52,7 +56,7 @@ export async function create (context, sharedAccountData) {
52
56
  * @throws {Error} If the creation of the shared account permissions fails
53
57
  */
54
58
  export async function createSharedAccountPermissions (context, sharedAccountContext, sharedAccountData, mailConfig, calendarConfig, users = [], groups = []) {
55
- return (await OXSharedAccountService).createSharedAccountPermissionsAsync({
59
+ return (await getClient()).createSharedAccountPermissionsAsync({
56
60
  ctx: { id: context.id },
57
61
  groups,
58
62
  users: users.map(user => { return { id: user.userdata.id } }),
@@ -72,7 +76,7 @@ export async function createSharedAccountPermissions (context, sharedAccountCont
72
76
  * @returns {Promise<Object[]>} The list of shared account objects
73
77
  */
74
78
  export async function list (context, pattern = '*') {
75
- return (await OXSharedAccountService).listAsync({
79
+ return (await getClient()).listAsync({
76
80
  ctx: { id: context.id },
77
81
  search_pattern: pattern,
78
82
  auth: context.admin
@@ -87,7 +91,7 @@ export async function list (context, pattern = '*') {
87
91
  * @returns {Promise<Object>} The shared account object
88
92
  */
89
93
  export async function getData (context, sharedAccountData) {
90
- return (await OXSharedAccountService).getDataAsync({
94
+ return (await getClient()).getDataAsync({
91
95
  ctx: { id: context.id },
92
96
  sharedAccount: { id: sharedAccountData.id },
93
97
  auth: context.admin
@@ -102,7 +106,7 @@ export async function getData (context, sharedAccountData) {
102
106
  * @returns {Promise<void>}
103
107
  */
104
108
  export async function remove (context, sharedAccountData) {
105
- return (await OXSharedAccountService).deleteAsync({
109
+ return (await getClient()).deleteAsync({
106
110
  ctx: { id: context.id },
107
111
  sharedAccount: { id: sharedAccountData.id },
108
112
  auth: context.admin