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