@api-client/core 0.8.22 → 0.9.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 (207) hide show
  1. package/build/browser.d.ts +12 -5
  2. package/build/browser.js +2 -3
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +12 -5
  5. package/build/index.js +2 -4
  6. package/build/index.js.map +1 -1
  7. package/build/src/events/BaseEvents.d.ts +137 -18
  8. package/build/src/events/BaseEvents.js.map +1 -1
  9. package/build/src/events/EventTypes.d.ts +0 -14
  10. package/build/src/events/EventTypes.js +0 -2
  11. package/build/src/events/EventTypes.js.map +1 -1
  12. package/build/src/events/Events.d.ts +1 -5
  13. package/build/src/events/Events.js +0 -2
  14. package/build/src/events/Events.js.map +1 -1
  15. package/build/src/events/transport/TransportEventTypes.d.ts +0 -1
  16. package/build/src/events/transport/TransportEventTypes.js +0 -1
  17. package/build/src/events/transport/TransportEventTypes.js.map +1 -1
  18. package/build/src/events/transport/TransportEvents.d.ts +0 -8
  19. package/build/src/events/transport/TransportEvents.js +0 -11
  20. package/build/src/events/transport/TransportEvents.js.map +1 -1
  21. package/build/src/mocking/ProjectMock.d.ts +0 -3
  22. package/build/src/mocking/ProjectMock.js +0 -3
  23. package/build/src/mocking/ProjectMock.js.map +1 -1
  24. package/build/src/mocking/lib/History.js +5 -0
  25. package/build/src/mocking/lib/History.js.map +1 -1
  26. package/build/src/models/{Workspace.d.ts → Folder.d.ts} +7 -7
  27. package/build/src/models/{Workspace.js → Folder.js} +5 -5
  28. package/build/src/models/Folder.js.map +1 -0
  29. package/build/src/models/HttpHistory.d.ts +38 -43
  30. package/build/src/models/HttpHistory.js +27 -34
  31. package/build/src/models/HttpHistory.js.map +1 -1
  32. package/build/src/models/HttpProject.d.ts +0 -2
  33. package/build/src/models/HttpProject.js +0 -27
  34. package/build/src/models/HttpProject.js.map +1 -1
  35. package/build/src/models/Project.d.ts +0 -8
  36. package/build/src/models/Project.js +0 -4
  37. package/build/src/models/Project.js.map +1 -1
  38. package/build/src/models/ProjectFolder.d.ts +0 -2
  39. package/build/src/models/ProjectFolder.js +0 -14
  40. package/build/src/models/ProjectFolder.js.map +1 -1
  41. package/build/src/models/ProjectItem.d.ts +0 -2
  42. package/build/src/models/ProjectItem.js +0 -20
  43. package/build/src/models/ProjectItem.js.map +1 -1
  44. package/build/src/models/ProjectRequest.d.ts +2 -3
  45. package/build/src/models/ProjectRequest.js.map +1 -1
  46. package/build/src/models/RequestConfig.d.ts +1 -1
  47. package/build/src/models/Space.d.ts +25 -0
  48. package/build/src/models/Space.js +76 -0
  49. package/build/src/models/Space.js.map +1 -0
  50. package/build/src/models/TrashEntry.d.ts +27 -0
  51. package/build/src/models/TrashEntry.js +2 -0
  52. package/build/src/models/TrashEntry.js.map +1 -0
  53. package/build/src/models/store/Backend.d.ts +0 -315
  54. package/build/src/models/store/Backend.js +0 -1
  55. package/build/src/models/store/Backend.js.map +1 -1
  56. package/build/src/models/store/File.d.ts +31 -1
  57. package/build/src/models/store/File.js +6 -6
  58. package/build/src/models/store/File.js.map +1 -1
  59. package/build/src/proxy/HttpProjectProxy.d.ts +4 -0
  60. package/build/src/proxy/HttpProjectProxy.js +10 -2
  61. package/build/src/proxy/HttpProjectProxy.js.map +1 -1
  62. package/build/src/proxy/ProxyService.d.ts +0 -10
  63. package/build/src/proxy/ProxyService.js +0 -14
  64. package/build/src/proxy/ProxyService.js.map +1 -1
  65. package/build/src/runtime/node/InteropInterfaces.d.ts +1 -2
  66. package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -3
  67. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
  68. package/build/src/runtime/node/ProjectRequestRunner.d.ts +7 -8
  69. package/build/src/runtime/node/ProjectRequestRunner.js +2 -3
  70. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  71. package/build/src/runtime/node/ProjectRunner.d.ts +3 -4
  72. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  73. package/build/src/runtime/node/ProjectRunnerWorker.js +0 -4
  74. package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
  75. package/build/src/runtime/store/CertificatesSdk.d.ts +46 -0
  76. package/build/src/runtime/store/CertificatesSdk.js +227 -0
  77. package/build/src/runtime/store/CertificatesSdk.js.map +1 -0
  78. package/build/src/runtime/store/FilesSdk.d.ts +21 -16
  79. package/build/src/runtime/store/FilesSdk.js +75 -23
  80. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  81. package/build/src/runtime/store/HistorySdk.d.ts +11 -8
  82. package/build/src/runtime/store/HistorySdk.js +140 -17
  83. package/build/src/runtime/store/HistorySdk.js.map +1 -1
  84. package/build/src/runtime/store/RevisionsSdk.d.ts +12 -0
  85. package/build/src/runtime/store/RevisionsSdk.js +43 -0
  86. package/build/src/runtime/store/RevisionsSdk.js.map +1 -0
  87. package/build/src/runtime/store/RouteBuilder.d.ts +16 -18
  88. package/build/src/runtime/store/RouteBuilder.js +33 -60
  89. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  90. package/build/src/runtime/store/Sdk.d.ts +10 -7
  91. package/build/src/runtime/store/Sdk.js +12 -5
  92. package/build/src/runtime/store/Sdk.js.map +1 -1
  93. package/build/src/runtime/store/SdkBase.js.map +1 -1
  94. package/build/src/runtime/store/SharedSdk.d.ts +2 -2
  95. package/build/src/runtime/store/SharedSdk.js.map +1 -1
  96. package/build/src/runtime/store/SpacesSdk.d.ts +29 -0
  97. package/build/src/runtime/store/SpacesSdk.js +135 -0
  98. package/build/src/runtime/store/SpacesSdk.js.map +1 -0
  99. package/build/src/runtime/store/TrashSdk.d.ts +35 -0
  100. package/build/src/runtime/store/TrashSdk.js +155 -0
  101. package/build/src/runtime/store/TrashSdk.js.map +1 -0
  102. package/build/src/runtime/store/UsersSdk.d.ts +2 -2
  103. package/build/src/runtime/store/UsersSdk.js.map +1 -1
  104. package/build/src/runtime/store/interfaces/ApiClientStore.d.ts +30 -0
  105. package/build/src/runtime/store/interfaces/ApiClientStore.js +2 -0
  106. package/build/src/runtime/store/interfaces/ApiClientStore.js.map +1 -0
  107. package/build/src/runtime/store/interfaces/Certificates.d.ts +49 -0
  108. package/build/src/runtime/store/interfaces/Certificates.js +2 -0
  109. package/build/src/runtime/store/interfaces/Certificates.js.map +1 -0
  110. package/build/src/runtime/store/interfaces/Files.d.ts +63 -0
  111. package/build/src/runtime/store/interfaces/Files.js +2 -0
  112. package/build/src/runtime/store/interfaces/Files.js.map +1 -0
  113. package/build/src/runtime/store/interfaces/History.d.ts +63 -0
  114. package/build/src/runtime/store/interfaces/History.js +2 -0
  115. package/build/src/runtime/store/interfaces/History.js.map +1 -0
  116. package/build/src/runtime/store/interfaces/Media.d.ts +42 -0
  117. package/build/src/runtime/store/interfaces/Media.js +2 -0
  118. package/build/src/runtime/store/interfaces/Media.js.map +1 -0
  119. package/build/src/runtime/store/interfaces/Revisions.d.ts +25 -0
  120. package/build/src/runtime/store/interfaces/Revisions.js +2 -0
  121. package/build/src/runtime/store/interfaces/Revisions.js.map +1 -0
  122. package/build/src/runtime/store/interfaces/Spaces.d.ts +42 -0
  123. package/build/src/runtime/store/interfaces/Spaces.js +2 -0
  124. package/build/src/runtime/store/interfaces/Spaces.js.map +1 -0
  125. package/build/src/runtime/store/interfaces/Trash.d.ts +38 -0
  126. package/build/src/runtime/store/interfaces/Trash.js +2 -0
  127. package/build/src/runtime/store/interfaces/Trash.js.map +1 -0
  128. package/package.json +1 -1
  129. package/src/events/BaseEvents.ts +148 -18
  130. package/src/events/EventTypes.ts +0 -2
  131. package/src/events/Events.ts +0 -2
  132. package/src/events/transport/TransportEventTypes.ts +0 -1
  133. package/src/events/transport/TransportEvents.ts +0 -13
  134. package/src/mocking/ProjectMock.ts +0 -4
  135. package/src/mocking/lib/History.ts +5 -0
  136. package/src/models/{Workspace.ts → Folder.ts} +12 -12
  137. package/src/models/HttpHistory.ts +53 -63
  138. package/src/models/HttpProject.ts +0 -29
  139. package/src/models/Project.ts +0 -8
  140. package/src/models/ProjectFolder.ts +0 -16
  141. package/src/models/ProjectItem.ts +0 -18
  142. package/src/models/ProjectRequest.ts +3 -4
  143. package/src/models/RequestConfig.ts +1 -1
  144. package/src/models/Space.ts +91 -0
  145. package/src/models/TrashEntry.ts +29 -0
  146. package/src/models/store/Backend.ts +0 -342
  147. package/src/models/store/File.ts +39 -6
  148. package/src/proxy/HttpProjectProxy.ts +14 -2
  149. package/src/proxy/ProxyService.ts +0 -15
  150. package/src/proxy/readme.md +0 -1
  151. package/src/runtime/node/InteropInterfaces.ts +1 -2
  152. package/src/runtime/node/ProjectParallelRunner.ts +2 -3
  153. package/src/runtime/node/ProjectRequestRunner.ts +13 -14
  154. package/src/runtime/node/ProjectRunner.ts +3 -4
  155. package/src/runtime/node/ProjectRunnerWorker.ts +1 -4
  156. package/src/runtime/store/CertificatesSdk.ts +231 -0
  157. package/src/runtime/store/FilesSdk.ts +88 -35
  158. package/src/runtime/store/HistorySdk.ts +145 -33
  159. package/src/runtime/store/RevisionsSdk.ts +44 -0
  160. package/src/runtime/store/RouteBuilder.ts +37 -69
  161. package/src/runtime/store/Sdk.ts +17 -7
  162. package/src/runtime/store/SdkBase.ts +1 -1
  163. package/src/runtime/store/SharedSdk.ts +3 -3
  164. package/src/runtime/store/SpacesSdk.ts +136 -0
  165. package/src/runtime/store/TrashSdk.ts +159 -0
  166. package/src/runtime/store/UsersSdk.ts +3 -3
  167. package/src/runtime/store/interfaces/ApiClientStore.ts +39 -0
  168. package/src/runtime/store/interfaces/Certificates.ts +56 -0
  169. package/src/runtime/store/interfaces/Files.ts +70 -0
  170. package/src/runtime/store/interfaces/History.ts +64 -0
  171. package/src/runtime/store/interfaces/Media.ts +46 -0
  172. package/src/runtime/store/interfaces/Revisions.ts +27 -0
  173. package/src/runtime/store/interfaces/Spaces.ts +48 -0
  174. package/src/runtime/store/interfaces/Trash.ts +42 -0
  175. package/build/src/events/models/ClientCertificateEvents.d.ts +0 -54
  176. package/build/src/events/models/ClientCertificateEvents.js +0 -78
  177. package/build/src/events/models/ClientCertificateEvents.js.map +0 -1
  178. package/build/src/events/models/ModelEventTypes.d.ts +0 -13
  179. package/build/src/events/models/ModelEventTypes.js +0 -14
  180. package/build/src/events/models/ModelEventTypes.js.map +0 -1
  181. package/build/src/events/models/ModelEvents.d.ts +0 -4
  182. package/build/src/events/models/ModelEvents.js +0 -5
  183. package/build/src/events/models/ModelEvents.js.map +0 -1
  184. package/build/src/mocking/lib/App.d.ts +0 -36
  185. package/build/src/mocking/lib/App.js +0 -70
  186. package/build/src/mocking/lib/App.js.map +0 -1
  187. package/build/src/models/AppProject.d.ts +0 -817
  188. package/build/src/models/AppProject.js +0 -1721
  189. package/build/src/models/AppProject.js.map +0 -1
  190. package/build/src/models/AppRequest.d.ts +0 -69
  191. package/build/src/models/AppRequest.js +0 -150
  192. package/build/src/models/AppRequest.js.map +0 -1
  193. package/build/src/models/Workspace.js.map +0 -1
  194. package/build/src/proxy/AppProjectProxy.d.ts +0 -28
  195. package/build/src/proxy/AppProjectProxy.js +0 -107
  196. package/build/src/proxy/AppProjectProxy.js.map +0 -1
  197. package/build/src/runtime/store/AppSdk.d.ts +0 -213
  198. package/build/src/runtime/store/AppSdk.js +0 -836
  199. package/build/src/runtime/store/AppSdk.js.map +0 -1
  200. package/src/events/models/ClientCertificateEvents.ts +0 -85
  201. package/src/events/models/ModelEventTypes.ts +0 -13
  202. package/src/events/models/ModelEvents.ts +0 -5
  203. package/src/mocking/lib/App.ts +0 -101
  204. package/src/models/AppProject.ts +0 -2188
  205. package/src/models/AppRequest.ts +0 -176
  206. package/src/proxy/AppProjectProxy.ts +0 -126
  207. package/src/runtime/store/AppSdk.ts +0 -842
@@ -1,836 +0,0 @@
1
- import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN } from './SdkBase.js';
2
- import { RouteBuilder } from './RouteBuilder.js';
3
- import { Kind as AppRequestKind } from '../../models/AppRequest.js';
4
- import { AppProjectKind } from '../../models/AppProject.js';
5
- import { SdkError } from './Errors.js';
6
- /**
7
- * SDK for the Application HTTP requests.
8
- */
9
- export class AppRequestsSdk extends SdkBase {
10
- /**
11
- * Adds a single HTTP request to the app.
12
- *
13
- * @param value The HTTP request to add.
14
- * @param appId The application id for which to create the request.
15
- * @param request Optional request options
16
- * @returns The created AppRequest with updated server-side properties.
17
- */
18
- async create(value, appId, request = {}) {
19
- if (!value) {
20
- throw new Error(`Expected a value when inserting an app request.`);
21
- }
22
- const token = request.token || this.sdk.token;
23
- const url = this.sdk.getUrl(RouteBuilder.appRequests(appId));
24
- const body = JSON.stringify(value);
25
- const result = await this.sdk.http.post(url.toString(), { token, body });
26
- this.inspectCommonStatusCodes(result.status);
27
- const E_PREFIX = 'Unable to create the app request. ';
28
- if (result.status !== 200) {
29
- this.logInvalidResponse(result);
30
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
31
- }
32
- if (!result.body) {
33
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
34
- }
35
- let data;
36
- try {
37
- data = JSON.parse(result.body);
38
- }
39
- catch (e) {
40
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
41
- }
42
- if (data.kind !== AppRequestKind) {
43
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
44
- }
45
- return data;
46
- }
47
- /**
48
- * Lists application requests.
49
- *
50
- * @param appId The application id to which lists the requests.
51
- * @param options List query options.
52
- * @param request Optional request options
53
- * @returns The list response with `AppRequest`s
54
- */
55
- async list(appId, options, request = {}) {
56
- const token = request.token || this.sdk.token;
57
- const url = this.sdk.getUrl(RouteBuilder.appRequests(appId));
58
- this.sdk.appendListOptions(url, options);
59
- const result = await this.sdk.http.get(url.toString(), { token });
60
- this.inspectCommonStatusCodes(result.status);
61
- const E_PREFIX = 'Unable to list app request. ';
62
- if (result.status !== 200) {
63
- this.logInvalidResponse(result);
64
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
65
- }
66
- if (!result.body) {
67
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
68
- }
69
- let data;
70
- try {
71
- data = JSON.parse(result.body);
72
- }
73
- catch (e) {
74
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
75
- }
76
- if (!Array.isArray(data.items)) {
77
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
78
- }
79
- return data;
80
- }
81
- /**
82
- * Creates a number of `AppRequest`s in a batch operation.
83
- *
84
- * @param values The `AppRequest`s list to insert.
85
- * @param appId The application id generating these requests.
86
- * @param request Optional request options
87
- * @returns The ordered list of created requests.
88
- */
89
- async createBatch(values, appId, request = {}) {
90
- if (!Array.isArray(values)) {
91
- throw new Error(`Expected a value when inserting app request list.`);
92
- }
93
- const token = request.token || this.sdk.token;
94
- const url = this.sdk.getUrl(RouteBuilder.appRequestsBatchCreate(appId));
95
- const content = {
96
- items: values,
97
- };
98
- const body = JSON.stringify(content);
99
- const result = await this.sdk.http.post(url.toString(), { token, body });
100
- this.inspectCommonStatusCodes(result.status);
101
- const E_PREFIX = 'Unable to create an app request in bulk. ';
102
- if (result.status !== 200) {
103
- this.logInvalidResponse(result);
104
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
105
- }
106
- if (!result.body) {
107
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
108
- }
109
- let data;
110
- try {
111
- data = JSON.parse(result.body);
112
- }
113
- catch (e) {
114
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
115
- }
116
- if (!Array.isArray(data.items)) {
117
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
118
- }
119
- return data;
120
- }
121
- /**
122
- * Reads `AppRequest`s in a batch operation.
123
- *
124
- * @param keys The list of request keys to read.
125
- * @param appId The application id that generated the app requests.
126
- * @param request Optional HTTP request options
127
- * @returns The ordered list of results. The undefined/null value means the object couldn't be read (does not exists or no access).
128
- */
129
- async readBatch(keys, appId, request = {}) {
130
- const token = request.token || this.sdk.token;
131
- const url = this.sdk.getUrl(RouteBuilder.appRequestsBatchRead(appId));
132
- const body = JSON.stringify(keys);
133
- const result = await this.sdk.http.post(url.toString(), { token, body });
134
- this.inspectCommonStatusCodes(result.status, result.body);
135
- const E_PREFIX = 'Unable to read app request in bulk. ';
136
- if (result.status !== 200) {
137
- this.logInvalidResponse(result);
138
- let e = this.createGenericSdkError(result.body);
139
- if (!e) {
140
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
141
- e.response = result.body;
142
- }
143
- throw e;
144
- }
145
- if (!result.body) {
146
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
147
- }
148
- let data;
149
- try {
150
- data = JSON.parse(result.body);
151
- }
152
- catch (e) {
153
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
154
- }
155
- if (!Array.isArray(data.items)) {
156
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
157
- }
158
- return data;
159
- }
160
- /**
161
- * Deletes `AppRequest`s in a batch operation.
162
- *
163
- * @param keys The list of request keys to delete.
164
- * @param appId The application id that generated the app requests.
165
- * @param request Optional HTTP request options
166
- * @returns A delete record for each request or null/undefined when couldn't delete the record.
167
- */
168
- async deleteBatch(keys, appId, request = {}) {
169
- const token = request.token || this.sdk.token;
170
- const url = this.sdk.getUrl(RouteBuilder.appRequestsBatchDelete(appId));
171
- const body = JSON.stringify(keys);
172
- const result = await this.sdk.http.post(url.toString(), { token, body });
173
- this.inspectCommonStatusCodes(result.status, result.body);
174
- const E_PREFIX = 'Unable to delete an app request in bulk. ';
175
- if (result.status !== 200) {
176
- this.logInvalidResponse(result);
177
- let e = this.createGenericSdkError(result.body);
178
- if (!e) {
179
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
180
- e.response = result.body;
181
- }
182
- throw e;
183
- }
184
- if (!result.body) {
185
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
186
- }
187
- let data;
188
- try {
189
- data = JSON.parse(result.body);
190
- }
191
- catch (e) {
192
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
193
- }
194
- if (!Array.isArray(data.items)) {
195
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
196
- }
197
- return data;
198
- }
199
- /**
200
- * Restores previously deleted `AppRequest`s.
201
- *
202
- * @param keys The list of keys of deleted records.
203
- * @param appId The application id that generated the app requests.
204
- * @param request Optional HTTP request options
205
- * @returns The ordered list of the restored requests. An item can be null/undefined when the service couldn't restore the request.
206
- */
207
- async undeleteBatch(keys, appId, request = {}) {
208
- if (!keys) {
209
- throw new Error(`The "records" argument is missing.`);
210
- }
211
- if (!Array.isArray(keys)) {
212
- throw new Error(`The "records" argument expected to be an array.`);
213
- }
214
- const token = request.token || this.sdk.token;
215
- const url = this.sdk.getUrl(RouteBuilder.appRequestsBatchUndelete(appId));
216
- const body = JSON.stringify(keys);
217
- const result = await this.sdk.http.post(url.toString(), { token, body });
218
- this.inspectCommonStatusCodes(result.status, result.body);
219
- const E_PREFIX = 'Unable to restore app request in bulk. ';
220
- if (result.status !== 200) {
221
- this.logInvalidResponse(result);
222
- let e = this.createGenericSdkError(result.body);
223
- if (!e) {
224
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
225
- e.response = result.body;
226
- }
227
- throw e;
228
- }
229
- if (!result.body) {
230
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
231
- }
232
- let data;
233
- try {
234
- data = JSON.parse(result.body);
235
- }
236
- catch (e) {
237
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
238
- }
239
- if (!Array.isArray(data.items)) {
240
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
241
- }
242
- return data;
243
- }
244
- /**
245
- * Reads a single AppRequest entry from the store.
246
- *
247
- * @param key The key of the request to read.
248
- * @param appId The application id that created this entry.
249
- * @param request Optional request options
250
- * @returns The stored AppRequest.
251
- */
252
- async read(key, appId, request = {}) {
253
- const token = request.token || this.sdk.token;
254
- const url = this.sdk.getUrl(RouteBuilder.appRequestItem(appId, key));
255
- const result = await this.sdk.http.get(url.toString(), { token });
256
- this.inspectCommonStatusCodes(result.status, result.body);
257
- const E_PREFIX = 'Unable to read app request. ';
258
- if (result.status !== 200) {
259
- this.logInvalidResponse(result);
260
- let e = this.createGenericSdkError(result.body);
261
- if (!e) {
262
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
263
- e.response = result.body;
264
- }
265
- throw e;
266
- }
267
- if (!result.body) {
268
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
269
- }
270
- let data;
271
- try {
272
- data = JSON.parse(result.body);
273
- }
274
- catch (e) {
275
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
276
- }
277
- if (data.kind !== AppRequestKind) {
278
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
279
- }
280
- return data;
281
- }
282
- /**
283
- * Deletes a single AppRequest.
284
- *
285
- * @param key The key of the AppRequest to delete.
286
- * @param appId The application id that created this entry.
287
- * @param request Optional request options
288
- * @returns The delete record for the request.
289
- */
290
- async delete(key, appId, request = {}) {
291
- const token = request.token || this.sdk.token;
292
- const url = this.sdk.getUrl(RouteBuilder.appRequestItem(appId, key));
293
- url.searchParams.set('appId', appId);
294
- const result = await this.sdk.http.delete(url.toString(), { token });
295
- this.inspectCommonStatusCodes(result.status, result.body);
296
- const E_PREFIX = 'Unable to delete an app request. ';
297
- if (result.status !== 200) {
298
- this.logInvalidResponse(result);
299
- let e = this.createGenericSdkError(result.body);
300
- if (!e) {
301
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
302
- e.response = result.body;
303
- }
304
- throw e;
305
- }
306
- if (!result.body) {
307
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
308
- }
309
- let data;
310
- try {
311
- data = JSON.parse(result.body);
312
- }
313
- catch (e) {
314
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
315
- }
316
- return data;
317
- }
318
- /**
319
- * Patches an app request in the store.
320
- *
321
- * @param key The key of the request to patch
322
- * @param appId The application id that created this entry.
323
- * @param value The JSON patch to be processed.
324
- * @param request Optional HTTP request options.
325
- * @returns The JSON patch to revert the change using the `@api-client/json` library
326
- */
327
- async patch(key, appId, value, request = {}) {
328
- const token = request.token || this.sdk.token;
329
- const url = this.sdk.getUrl(RouteBuilder.appRequestItem(appId, key));
330
- const body = JSON.stringify(value);
331
- const result = await this.sdk.http.patch(url.toString(), { token, body });
332
- this.inspectCommonStatusCodes(result.status, result.body);
333
- const E_PREFIX = 'Unable to patch an app project. ';
334
- if (result.status !== 200) {
335
- this.logInvalidResponse(result);
336
- let e = this.createGenericSdkError(result.body);
337
- if (!e) {
338
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
339
- e.response = result.body;
340
- }
341
- throw e;
342
- }
343
- if (!result.body) {
344
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
345
- }
346
- let data;
347
- try {
348
- data = JSON.parse(result.body);
349
- }
350
- catch (e) {
351
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
352
- }
353
- // revert is added to the response
354
- if (!data.revert) {
355
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
356
- }
357
- return data;
358
- }
359
- /**
360
- * Performs a full-text search on the stored documents.
361
- *
362
- * @param appId The application id that created documents.
363
- * @param options Regular query options with required "query" property
364
- * @param request Optional HTTP request options.
365
- * @returns The list of documents with the indexes where the query was found.
366
- */
367
- async query(appId, options, request = {}) {
368
- const E_PREFIX = 'Unable to query app requests. ';
369
- if (!options.query) {
370
- throw new Error(`${E_PREFIX}The "query" property is required.`);
371
- }
372
- const token = request.token || this.sdk.token;
373
- const url = this.sdk.getUrl(RouteBuilder.appQueryRequests(appId));
374
- this.sdk.appendListOptions(url, options);
375
- const result = await this.sdk.http.get(url.toString(), { token });
376
- this.inspectCommonStatusCodes(result.status);
377
- if (result.status !== 200) {
378
- this.logInvalidResponse(result);
379
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
380
- }
381
- if (!result.body) {
382
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
383
- }
384
- let data;
385
- try {
386
- data = JSON.parse(result.body);
387
- }
388
- catch (e) {
389
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
390
- }
391
- if (!Array.isArray(data.items)) {
392
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
393
- }
394
- return data;
395
- }
396
- }
397
- /**
398
- * SDK for the Application projects.
399
- */
400
- export class AppProjectsSdk extends SdkBase {
401
- /**
402
- * Adds a single project to the app.
403
- *
404
- * @param value The project to add.
405
- * @param appId The application id for which to create the project.
406
- * @param request Optional request options
407
- * @returns The created project with updated server-side properties.
408
- */
409
- async create(value, appId, request = {}) {
410
- if (!value) {
411
- throw new Error(`Expected a value when inserting an app project.`);
412
- }
413
- const token = request.token || this.sdk.token;
414
- const url = this.sdk.getUrl(RouteBuilder.appProjects(appId));
415
- const body = JSON.stringify(value);
416
- const result = await this.sdk.http.post(url.toString(), { token, body });
417
- this.inspectCommonStatusCodes(result.status);
418
- const E_PREFIX = 'Unable to create the app project. ';
419
- if (result.status !== 200) {
420
- this.logInvalidResponse(result);
421
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
422
- }
423
- if (!result.body) {
424
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
425
- }
426
- let data;
427
- try {
428
- data = JSON.parse(result.body);
429
- }
430
- catch (e) {
431
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
432
- }
433
- if (data.kind !== AppProjectKind) {
434
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
435
- }
436
- return data;
437
- }
438
- /**
439
- * Lists application projects.
440
- *
441
- * @param appId The application id to which lists the projects.
442
- * @param options List query options.
443
- * @param request Optional request options
444
- * @returns The list response with `AppProject`s
445
- */
446
- async list(appId, options, request = {}) {
447
- const token = request.token || this.sdk.token;
448
- const url = this.sdk.getUrl(RouteBuilder.appProjects(appId));
449
- this.sdk.appendListOptions(url, options);
450
- const result = await this.sdk.http.get(url.toString(), { token });
451
- this.inspectCommonStatusCodes(result.status);
452
- const E_PREFIX = 'Unable to list app project. ';
453
- if (result.status !== 200) {
454
- this.logInvalidResponse(result);
455
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
456
- }
457
- if (!result.body) {
458
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
459
- }
460
- let data;
461
- try {
462
- data = JSON.parse(result.body);
463
- }
464
- catch (e) {
465
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
466
- }
467
- if (!Array.isArray(data.items)) {
468
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
469
- }
470
- return data;
471
- }
472
- /**
473
- * Creates a number of `AppProject`s in a batch operation.
474
- *
475
- * @param values The `AppProject`s list to insert.
476
- * @param appId The application id generating these projects.
477
- * @param request Optional request options
478
- * @returns The ordered list of created projects.
479
- */
480
- async createBatch(values, appId, request = {}) {
481
- if (!Array.isArray(values)) {
482
- throw new Error(`Expected a value when inserting app project list.`);
483
- }
484
- const token = request.token || this.sdk.token;
485
- const url = this.sdk.getUrl(RouteBuilder.appProjectsBatchCreate(appId));
486
- const content = {
487
- items: values,
488
- };
489
- const body = JSON.stringify(content);
490
- const result = await this.sdk.http.post(url.toString(), { token, body });
491
- this.inspectCommonStatusCodes(result.status);
492
- const E_PREFIX = 'Unable to create an app project in bulk. ';
493
- if (result.status !== 200) {
494
- this.logInvalidResponse(result);
495
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
496
- }
497
- if (!result.body) {
498
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
499
- }
500
- let data;
501
- try {
502
- data = JSON.parse(result.body);
503
- }
504
- catch (e) {
505
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
506
- }
507
- if (!Array.isArray(data.items)) {
508
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
509
- }
510
- return data;
511
- }
512
- /**
513
- * Reads `AppProject`s in a batch operation.
514
- *
515
- * @param keys The list of project keys to read.
516
- * @param appId The application id that generated the app projects.
517
- * @param request Optional HTTP request options
518
- * @returns The ordered list of results. The undefined/null value means the object couldn't be read (does not exists or no access).
519
- */
520
- async readBatch(keys, appId, request = {}) {
521
- const token = request.token || this.sdk.token;
522
- const url = this.sdk.getUrl(RouteBuilder.appProjectsBatchRead(appId));
523
- const body = JSON.stringify(keys);
524
- const result = await this.sdk.http.post(url.toString(), { token, body });
525
- this.inspectCommonStatusCodes(result.status, result.body);
526
- const E_PREFIX = 'Unable to read app project in bulk. ';
527
- if (result.status !== 200) {
528
- this.logInvalidResponse(result);
529
- let e = this.createGenericSdkError(result.body);
530
- if (!e) {
531
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
532
- e.response = result.body;
533
- }
534
- throw e;
535
- }
536
- if (!result.body) {
537
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
538
- }
539
- let data;
540
- try {
541
- data = JSON.parse(result.body);
542
- }
543
- catch (e) {
544
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
545
- }
546
- if (!Array.isArray(data.items)) {
547
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
548
- }
549
- return data;
550
- }
551
- /**
552
- * Deletes `AppProject`s in a batch operation.
553
- *
554
- * @param keys The list of project keys to delete.
555
- * @param appId The application id that generated the app projects.
556
- * @param request Optional HTTP request options
557
- * @returns A delete record for each project or null/undefined when couldn't delete the record.
558
- */
559
- async deleteBatch(keys, appId, request = {}) {
560
- const token = request.token || this.sdk.token;
561
- const url = this.sdk.getUrl(RouteBuilder.appProjectsBatchDelete(appId));
562
- const body = JSON.stringify(keys);
563
- const result = await this.sdk.http.post(url.toString(), { token, body });
564
- this.inspectCommonStatusCodes(result.status, result.body);
565
- const E_PREFIX = 'Unable to delete an app project in bulk. ';
566
- if (result.status !== 200) {
567
- this.logInvalidResponse(result);
568
- let e = this.createGenericSdkError(result.body);
569
- if (!e) {
570
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
571
- e.response = result.body;
572
- }
573
- throw e;
574
- }
575
- if (!result.body) {
576
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
577
- }
578
- let data;
579
- try {
580
- data = JSON.parse(result.body);
581
- }
582
- catch (e) {
583
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
584
- }
585
- if (!Array.isArray(data.items)) {
586
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
587
- }
588
- return data;
589
- }
590
- /**
591
- * Restores previously deleted `AppProject`s.
592
- *
593
- * @param keys The list of keys of deleted records.
594
- * @param appId The application id that generated the app projects.
595
- * @param request Optional HTTP request options
596
- * @returns The ordered list of the restored projects. An item can be null/undefined when the service couldn't restore the project.
597
- */
598
- async undeleteBatch(keys, appId, request = {}) {
599
- if (!keys) {
600
- throw new Error(`The "records" argument is missing.`);
601
- }
602
- if (!Array.isArray(keys)) {
603
- throw new Error(`The "records" argument expected to be an array.`);
604
- }
605
- const token = request.token || this.sdk.token;
606
- const url = this.sdk.getUrl(RouteBuilder.appProjectsBatchUndelete(appId));
607
- const body = JSON.stringify(keys);
608
- const result = await this.sdk.http.post(url.toString(), { token, body });
609
- this.inspectCommonStatusCodes(result.status, result.body);
610
- const E_PREFIX = 'Unable to restore app project in bulk. ';
611
- if (result.status !== 200) {
612
- this.logInvalidResponse(result);
613
- let e = this.createGenericSdkError(result.body);
614
- if (!e) {
615
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
616
- e.response = result.body;
617
- }
618
- throw e;
619
- }
620
- if (!result.body) {
621
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
622
- }
623
- let data;
624
- try {
625
- data = JSON.parse(result.body);
626
- }
627
- catch (e) {
628
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
629
- }
630
- if (!Array.isArray(data.items)) {
631
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
632
- }
633
- return data;
634
- }
635
- /**
636
- * Reads a single AppProject entry from the store.
637
- *
638
- * @param key The key of the project to read.
639
- * @param appId The application id that created this entry.
640
- * @param request Optional request options
641
- * @returns The stored AppProject.
642
- */
643
- async read(key, appId, request = {}) {
644
- const token = request.token || this.sdk.token;
645
- const url = this.sdk.getUrl(RouteBuilder.appProjectItem(appId, key));
646
- const result = await this.sdk.http.get(url.toString(), { token });
647
- this.inspectCommonStatusCodes(result.status, result.body);
648
- const E_PREFIX = 'Unable to read app project. ';
649
- if (result.status !== 200) {
650
- this.logInvalidResponse(result);
651
- let e = this.createGenericSdkError(result.body);
652
- if (!e) {
653
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
654
- e.response = result.body;
655
- }
656
- throw e;
657
- }
658
- if (!result.body) {
659
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
660
- }
661
- let data;
662
- try {
663
- data = JSON.parse(result.body);
664
- }
665
- catch (e) {
666
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
667
- }
668
- if (data.kind !== AppProjectKind) {
669
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
670
- }
671
- return data;
672
- }
673
- /**
674
- * Deletes a single `AppProject`.
675
- *
676
- * @param key The key of the `AppProject` to delete.
677
- * @param appId The application id that created this entry.
678
- * @param request Optional request options
679
- * @returns The delete record for the project.
680
- */
681
- async delete(key, appId, request = {}) {
682
- const token = request.token || this.sdk.token;
683
- const url = this.sdk.getUrl(RouteBuilder.appProjectItem(appId, key));
684
- url.searchParams.set('appId', appId);
685
- const result = await this.sdk.http.delete(url.toString(), { token });
686
- this.inspectCommonStatusCodes(result.status, result.body);
687
- const E_PREFIX = 'Unable to delete an app project. ';
688
- if (result.status !== 200) {
689
- this.logInvalidResponse(result);
690
- let e = this.createGenericSdkError(result.body);
691
- if (!e) {
692
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
693
- e.response = result.body;
694
- }
695
- throw e;
696
- }
697
- if (!result.body) {
698
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
699
- }
700
- let data;
701
- try {
702
- data = JSON.parse(result.body);
703
- }
704
- catch (e) {
705
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
706
- }
707
- return data;
708
- }
709
- /**
710
- * Patches an app project in the store.
711
- *
712
- * @param key The key of the project to patch
713
- * @param value The JSON patch to be processed.
714
- * @param request Optional request options.
715
- * @returns The JSON patch to revert the change using the `@api-client/json` library
716
- */
717
- async patch(key, appId, value, request = {}) {
718
- const token = request.token || this.sdk.token;
719
- const url = this.sdk.getUrl(RouteBuilder.appProjectItem(appId, key));
720
- const body = JSON.stringify(value);
721
- const result = await this.sdk.http.patch(url.toString(), { token, body });
722
- this.inspectCommonStatusCodes(result.status, result.body);
723
- const E_PREFIX = 'Unable to patch an app project. ';
724
- if (result.status !== 200) {
725
- this.logInvalidResponse(result);
726
- let e = this.createGenericSdkError(result.body);
727
- if (!e) {
728
- e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
729
- e.response = result.body;
730
- }
731
- throw e;
732
- }
733
- if (!result.body) {
734
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
735
- }
736
- let data;
737
- try {
738
- data = JSON.parse(result.body);
739
- }
740
- catch (e) {
741
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
742
- }
743
- // revert is added to the response
744
- if (!data.revert) {
745
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
746
- }
747
- return data;
748
- }
749
- /**
750
- * Performs a full-text search on the stored documents.
751
- *
752
- * @param appId The application id that created documents.
753
- * @param options Regular query options with required "query" property
754
- * @param request Optional HTTP request options.
755
- * @returns The list of documents with the indexes where the query was found.
756
- */
757
- async query(appId, options, request = {}) {
758
- const E_PREFIX = 'Unable to query app projects. ';
759
- if (!options.query) {
760
- throw new Error(`${E_PREFIX}The "query" property is required.`);
761
- }
762
- const token = request.token || this.sdk.token;
763
- const url = this.sdk.getUrl(RouteBuilder.appQueryProjects(appId));
764
- this.sdk.appendListOptions(url, options);
765
- const result = await this.sdk.http.get(url.toString(), { token });
766
- this.inspectCommonStatusCodes(result.status);
767
- if (result.status !== 200) {
768
- this.logInvalidResponse(result);
769
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
770
- }
771
- if (!result.body) {
772
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
773
- }
774
- let data;
775
- try {
776
- data = JSON.parse(result.body);
777
- }
778
- catch (e) {
779
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
780
- }
781
- if (!Array.isArray(data.items)) {
782
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
783
- }
784
- return data;
785
- }
786
- }
787
- /**
788
- * Sdk used by the HTTP Client.
789
- */
790
- export class AppSdk extends SdkBase {
791
- requests;
792
- projects;
793
- constructor(sdk) {
794
- super(sdk);
795
- this.requests = new AppRequestsSdk(sdk);
796
- this.projects = new AppProjectsSdk(sdk);
797
- }
798
- /**
799
- * Performs a full-text search on all supported application documents.
800
- *
801
- * @param appId The application id that created documents.
802
- * @param options Regular query options with required "query" property
803
- * @param request Optional HTTP request options.
804
- * @returns The list of documents with the indexes where the query was found.
805
- */
806
- async query(appId, options, request = {}) {
807
- const E_PREFIX = 'Unable to query app data. ';
808
- if (!options.query) {
809
- throw new Error(`${E_PREFIX}The "query" property is required.`);
810
- }
811
- const token = request.token || this.sdk.token;
812
- const url = this.sdk.getUrl(RouteBuilder.appQuery(appId));
813
- this.sdk.appendListOptions(url, options);
814
- const result = await this.sdk.http.get(url.toString(), { token });
815
- this.inspectCommonStatusCodes(result.status);
816
- if (result.status !== 200) {
817
- this.logInvalidResponse(result);
818
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
819
- }
820
- if (!result.body) {
821
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
822
- }
823
- let data;
824
- try {
825
- data = JSON.parse(result.body);
826
- }
827
- catch (e) {
828
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
829
- }
830
- if (!Array.isArray(data.items)) {
831
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
832
- }
833
- return data;
834
- }
835
- }
836
- //# sourceMappingURL=AppSdk.js.map