@api-client/core 0.6.31 → 0.7.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 +6 -14
- package/build/browser.js +11 -16
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +8 -20
- package/build/index.js +13 -25
- package/build/index.js.map +1 -1
- package/build/src/amf/ApiSchemaValues.d.ts +2 -0
- package/build/src/amf/ApiSchemaValues.js +29 -23
- package/build/src/amf/ApiSchemaValues.js.map +1 -1
- package/build/src/authorization/lib/Utils.d.ts +1 -1
- package/build/src/cookies/CookieJar.d.ts +23 -0
- package/build/src/cookies/CookieJar.js +3 -0
- package/build/src/cookies/CookieJar.js.map +1 -0
- package/build/src/cookies/CookieParser.d.ts +67 -0
- package/build/src/cookies/CookieParser.js +316 -0
- package/build/src/cookies/CookieParser.js.map +1 -0
- package/build/src/cookies/InMemoryCookieJar.d.ts +12 -0
- package/build/src/cookies/InMemoryCookieJar.js +68 -0
- package/build/src/cookies/InMemoryCookieJar.js.map +1 -0
- package/build/src/cookies/Punycode.d.ts +12 -0
- package/build/src/cookies/Punycode.js +124 -0
- package/build/src/cookies/Punycode.js.map +1 -0
- package/build/src/data/RequestDataExtractor.d.ts +8 -7
- package/build/src/data/RequestDataExtractor.js +8 -10
- package/build/src/data/RequestDataExtractor.js.map +1 -1
- package/build/src/events/CustomEvent.js +5 -0
- package/build/src/events/CustomEvent.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +43 -43
- package/build/src/events/amf/AmfEventTypes.d.ts +4 -4
- package/build/src/events/authorization/AuthorizationEventTypes.d.ts +4 -4
- package/build/src/events/cookies/CookieEventTypes.d.ts +9 -9
- package/build/src/events/encryption/EncryptionEventTypes.d.ts +2 -2
- package/build/src/events/environment/EnvironmentEventTypes.d.ts +1 -1
- package/build/src/events/models/ModelEventTypes.d.ts +7 -7
- package/build/src/events/process/ProcessEventTypes.d.ts +3 -3
- package/build/src/events/reporting/ReportingEventTypes.d.ts +1 -1
- package/build/src/events/telemetry/TelemetryEventTypes.d.ts +6 -6
- package/build/src/events/transport/TransportEventTypes.d.ts +6 -6
- package/build/src/events/transport/TransportEvents.d.ts +2 -2
- package/build/src/mocking/ProjectMock.d.ts +3 -2
- package/build/src/mocking/ProjectMock.js +3 -3
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/lib/App.d.ts +36 -0
- package/build/src/mocking/lib/App.js +70 -0
- package/build/src/mocking/lib/App.js.map +1 -0
- package/build/src/models/{arc/ArcProject.d.ts → AppProject.d.ts} +296 -134
- package/build/src/models/{arc/ArcProject.js → AppProject.js} +436 -79
- package/build/src/models/AppProject.js.map +1 -0
- package/build/src/models/AppRequest.d.ts +69 -0
- package/build/src/models/{arc/ArcHttpRequest.js → AppRequest.js} +53 -17
- package/build/src/models/AppRequest.js.map +1 -0
- package/build/src/models/ClientCertificate.d.ts +2 -2
- package/build/src/models/Environment.d.ts +8 -1
- package/build/src/models/Environment.js +21 -0
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/HostRule.d.ts +2 -2
- package/build/src/models/HttpCookie.d.ts +63 -12
- package/build/src/models/HttpCookie.js +178 -44
- package/build/src/models/HttpCookie.js.map +1 -1
- package/build/src/models/HttpHistory.d.ts +8 -3
- package/build/src/models/HttpHistory.js +3 -3
- package/build/src/models/HttpHistory.js.map +1 -1
- package/build/src/models/HttpProject.d.ts +34 -1
- package/build/src/models/HttpProject.js +104 -8
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts +2 -0
- package/build/src/models/ProjectFolder.js +14 -0
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectItem.d.ts +2 -0
- package/build/src/models/ProjectItem.js +20 -0
- package/build/src/models/ProjectItem.js.map +1 -1
- package/build/src/models/ProjectParent.js.map +1 -1
- package/build/src/models/ProjectRequest.d.ts +3 -2
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/Property.d.ts +2 -2
- package/build/src/models/Property.js +2 -2
- package/build/src/models/Property.js.map +1 -1
- package/build/src/models/Request.d.ts +16 -8
- package/build/src/models/Request.js +20 -15
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/RequestAuthorization.js.map +1 -1
- package/build/src/models/RequestUiMeta.d.ts +0 -14
- package/build/src/models/RequestUiMeta.js +1 -10
- package/build/src/models/RequestUiMeta.js.map +1 -1
- package/build/src/models/Server.d.ts +1 -2
- package/build/src/models/Server.js.map +1 -1
- package/build/src/models/http-actions/HttpActions.d.ts +256 -0
- package/build/src/models/http-actions/HttpActions.js +46 -0
- package/build/src/models/http-actions/HttpActions.js.map +1 -0
- package/build/src/models/http-actions/LegacyTranslator.d.ts +17 -0
- package/build/src/models/http-actions/LegacyTranslator.js +222 -0
- package/build/src/models/http-actions/LegacyTranslator.js.map +1 -0
- package/build/src/models/store/Backend.d.ts +136 -1
- package/build/src/models/store/File.d.ts +1 -1
- package/build/src/models/store/File.js +2 -0
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/User.d.ts +3 -3
- package/build/src/runtime/http-engine/CoreEngine.d.ts +2 -0
- package/build/src/runtime/http-engine/CoreEngine.js +1 -0
- package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.d.ts +13 -0
- package/build/src/runtime/http-engine/HttpEngine.js +39 -31
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/{actions/ConditionRunner.d.ts → http-runner/ConditionCheck.d.ts} +2 -2
- package/build/src/runtime/{actions/ConditionRunner.js → http-runner/ConditionCheck.js} +2 -2
- package/build/src/runtime/http-runner/ConditionCheck.js.map +1 -0
- package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +62 -0
- package/build/src/runtime/http-runner/HttpFlowRunner.js +217 -0
- package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -0
- package/build/src/runtime/{node/RequestFactory.d.ts → http-runner/HttpRequestRunner.d.ts} +40 -54
- package/build/src/runtime/http-runner/HttpRequestRunner.js +316 -0
- package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -0
- package/build/src/runtime/http-runner/HttpRuntimeEnvironment.d.ts +25 -0
- package/build/src/runtime/http-runner/HttpRuntimeEnvironment.js +2 -0
- package/build/src/runtime/http-runner/HttpRuntimeEnvironment.js.map +1 -0
- package/build/src/runtime/http-runner/RequestAuthorizationProcessor.d.ts +56 -0
- package/build/src/runtime/http-runner/RequestAuthorizationProcessor.js +143 -0
- package/build/src/runtime/http-runner/RequestAuthorizationProcessor.js.map +1 -0
- package/build/src/runtime/http-runner/RequestCookiesProcessor.d.ts +24 -0
- package/build/src/runtime/http-runner/RequestCookiesProcessor.js +65 -0
- package/build/src/runtime/http-runner/RequestCookiesProcessor.js.map +1 -0
- package/build/src/runtime/node/InteropInterfaces.d.ts +21 -6
- package/build/src/runtime/node/ProjectParallelRunner.js +3 -1
- package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +24 -10
- package/build/src/runtime/node/ProjectRequestRunner.js +116 -45
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts +5 -7
- package/build/src/runtime/node/ProjectRunner.js +30 -14
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunnerWorker.js +3 -0
- package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
- package/build/src/runtime/reporters/Reporter.d.ts +5 -0
- package/build/src/runtime/reporters/Reporter.js.map +1 -1
- package/build/src/runtime/store/FilesSdk.js +4 -4
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/src/runtime/store/HistorySdk.js +1 -1
- package/build/src/runtime/store/HistorySdk.js.map +1 -1
- package/build/src/runtime/store/HttpClientSdk.d.ts +167 -0
- package/build/src/runtime/store/HttpClientSdk.js +624 -0
- package/build/src/runtime/store/HttpClientSdk.js.map +1 -0
- package/build/src/runtime/store/RouteBuilder.d.ts +17 -2
- package/build/src/runtime/store/RouteBuilder.js +60 -3
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/Sdk.d.ts +5 -0
- package/build/src/runtime/store/Sdk.js +5 -0
- package/build/src/runtime/store/Sdk.js.map +1 -1
- package/build/src/runtime/store/SharedSdk.js +1 -1
- package/build/src/runtime/store/SharedSdk.js.map +1 -1
- package/build/src/runtime/store/UsersSdk.js +1 -1
- package/build/src/runtime/store/UsersSdk.js.map +1 -1
- package/package.json +2 -2
- package/src/amf/ApiSchemaValues.ts +41 -33
- package/src/cookies/CookieJar.ts +26 -0
- package/src/cookies/CookieParser.ts +327 -0
- package/src/cookies/InMemoryCookieJar.ts +70 -0
- package/src/cookies/Punycode.ts +133 -0
- package/src/data/RequestDataExtractor.ts +14 -15
- package/src/events/CustomEvent.ts +4 -0
- package/src/mocking/ProjectMock.ts +4 -3
- package/src/mocking/lib/App.ts +101 -0
- package/src/models/{arc/ArcProject.ts → AppProject.ts} +671 -225
- package/src/models/AppRequest.ts +176 -0
- package/src/models/ClientCertificate.ts +2 -2
- package/src/models/Environment.ts +24 -2
- package/src/models/HostRule.ts +2 -2
- package/src/models/HttpCookie.ts +210 -48
- package/src/models/HttpHistory.ts +12 -5
- package/src/models/HttpProject.ts +113 -10
- package/src/models/ProjectFolder.ts +16 -0
- package/src/models/ProjectItem.ts +18 -0
- package/src/models/ProjectParent.ts +4 -1
- package/src/models/ProjectRequest.ts +4 -3
- package/src/models/Property.ts +4 -4
- package/src/models/Request.ts +29 -19
- package/src/models/RequestAuthorization.ts +4 -4
- package/src/models/RequestUiMeta.ts +1 -21
- package/src/models/Server.ts +1 -2
- package/src/models/http-actions/HttpActions.ts +270 -0
- package/src/models/http-actions/LegacyTranslator.ts +223 -0
- package/src/models/store/Backend.ts +148 -2
- package/src/models/store/File.ts +3 -1
- package/src/models/store/User.ts +3 -3
- package/src/runtime/http-engine/CoreEngine.ts +3 -2
- package/src/runtime/http-engine/HttpEngine.ts +48 -30
- package/src/runtime/{actions/ConditionRunner.ts → http-runner/ConditionCheck.ts} +3 -3
- package/src/runtime/http-runner/HttpFlowRunner.ts +232 -0
- package/src/runtime/http-runner/HttpRequestRunner.ts +353 -0
- package/src/runtime/http-runner/HttpRuntimeEnvironment.ts +27 -0
- package/src/runtime/http-runner/RequestAuthorizationProcessor.ts +144 -0
- package/src/runtime/http-runner/RequestCookiesProcessor.ts +74 -0
- package/src/runtime/node/InteropInterfaces.ts +24 -6
- package/src/runtime/node/ProjectParallelRunner.ts +4 -2
- package/src/runtime/node/ProjectRequestRunner.ts +130 -60
- package/src/runtime/node/ProjectRunner.ts +37 -22
- package/src/runtime/node/ProjectRunnerWorker.ts +3 -0
- package/src/runtime/reporters/Reporter.ts +5 -0
- package/src/runtime/store/FilesSdk.ts +4 -4
- package/src/runtime/store/HistorySdk.ts +1 -1
- package/src/runtime/store/HttpClientSdk.ts +629 -0
- package/src/runtime/store/RouteBuilder.ts +75 -3
- package/src/runtime/store/Sdk.ts +6 -0
- package/src/runtime/store/SharedSdk.ts +1 -1
- package/src/runtime/store/UsersSdk.ts +1 -1
- package/build/src/lib/cookies/Cookie.d.ts +0 -123
- package/build/src/lib/cookies/Cookie.js +0 -257
- package/build/src/lib/cookies/Cookie.js.map +0 -1
- package/build/src/lib/cookies/Cookies.d.ts +0 -90
- package/build/src/lib/cookies/Cookies.js +0 -310
- package/build/src/lib/cookies/Cookies.js.map +0 -1
- package/build/src/lib/cookies/Utils.d.ts +0 -47
- package/build/src/lib/cookies/Utils.js +0 -163
- package/build/src/lib/cookies/Utils.js.map +0 -1
- package/build/src/mocking/lib/Arc.d.ts +0 -9
- package/build/src/mocking/lib/Arc.js +0 -24
- package/build/src/mocking/lib/Arc.js.map +0 -1
- package/build/src/models/RequestActions.d.ts +0 -65
- package/build/src/models/RequestActions.js +0 -114
- package/build/src/models/RequestActions.js.map +0 -1
- package/build/src/models/actions/Action.d.ts +0 -75
- package/build/src/models/actions/Action.js +0 -188
- package/build/src/models/actions/Action.js.map +0 -1
- package/build/src/models/actions/ActionView.d.ts +0 -15
- package/build/src/models/actions/ActionView.js +0 -33
- package/build/src/models/actions/ActionView.js.map +0 -1
- package/build/src/models/actions/Condition.d.ts +0 -81
- package/build/src/models/actions/Condition.js +0 -185
- package/build/src/models/actions/Condition.js.map +0 -1
- package/build/src/models/actions/ConditionView.d.ts +0 -17
- package/build/src/models/actions/ConditionView.js +0 -34
- package/build/src/models/actions/ConditionView.js.map +0 -1
- package/build/src/models/actions/Enums.d.ts +0 -26
- package/build/src/models/actions/Enums.js +0 -31
- package/build/src/models/actions/Enums.js.map +0 -1
- package/build/src/models/actions/RunnableAction.d.ts +0 -59
- package/build/src/models/actions/RunnableAction.js +0 -106
- package/build/src/models/actions/RunnableAction.js.map +0 -1
- package/build/src/models/actions/runnable/DeleteCookieAction.d.ts +0 -44
- package/build/src/models/actions/runnable/DeleteCookieAction.js +0 -92
- package/build/src/models/actions/runnable/DeleteCookieAction.js.map +0 -1
- package/build/src/models/actions/runnable/Runnable.d.ts +0 -8
- package/build/src/models/actions/runnable/Runnable.js +0 -4
- package/build/src/models/actions/runnable/Runnable.js.map +0 -1
- package/build/src/models/actions/runnable/SetCookieAction.d.ts +0 -87
- package/build/src/models/actions/runnable/SetCookieAction.js +0 -176
- package/build/src/models/actions/runnable/SetCookieAction.js.map +0 -1
- package/build/src/models/actions/runnable/SetVariableAction.d.ts +0 -31
- package/build/src/models/actions/runnable/SetVariableAction.js +0 -63
- package/build/src/models/actions/runnable/SetVariableAction.js.map +0 -1
- package/build/src/models/actions/runnable/index.d.ts +0 -7
- package/build/src/models/actions/runnable/index.js +0 -2
- package/build/src/models/actions/runnable/index.js.map +0 -1
- package/build/src/models/arc/ArcHttpRequest.d.ts +0 -40
- package/build/src/models/arc/ArcHttpRequest.js.map +0 -1
- package/build/src/models/arc/ArcProject.js.map +0 -1
- package/build/src/runtime/actions/ActionRunner.d.ts +0 -17
- package/build/src/runtime/actions/ActionRunner.js +0 -74
- package/build/src/runtime/actions/ActionRunner.js.map +0 -1
- package/build/src/runtime/actions/ConditionRunner.js.map +0 -1
- package/build/src/runtime/actions/RunnableCondition.d.ts +0 -27
- package/build/src/runtime/actions/RunnableCondition.js +0 -50
- package/build/src/runtime/actions/RunnableCondition.js.map +0 -1
- package/build/src/runtime/actions/runnable/ActionRunnable.d.ts +0 -13
- package/build/src/runtime/actions/runnable/ActionRunnable.js +0 -13
- package/build/src/runtime/actions/runnable/ActionRunnable.js.map +0 -1
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.d.ts +0 -7
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js +0 -36
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js.map +0 -1
- package/build/src/runtime/actions/runnable/SetCookieRunnable.d.ts +0 -10
- package/build/src/runtime/actions/runnable/SetCookieRunnable.js +0 -89
- package/build/src/runtime/actions/runnable/SetCookieRunnable.js.map +0 -1
- package/build/src/runtime/actions/runnable/SetVariableRunnable.d.ts +0 -10
- package/build/src/runtime/actions/runnable/SetVariableRunnable.js +0 -49
- package/build/src/runtime/actions/runnable/SetVariableRunnable.js.map +0 -1
- package/build/src/runtime/modules/BasicAuthCache.d.ts +0 -39
- package/build/src/runtime/modules/BasicAuthCache.js +0 -122
- package/build/src/runtime/modules/BasicAuthCache.js.map +0 -1
- package/build/src/runtime/modules/ExecutionResponse.d.ts +0 -4
- package/build/src/runtime/modules/ExecutionResponse.js +0 -6
- package/build/src/runtime/modules/ExecutionResponse.js.map +0 -1
- package/build/src/runtime/modules/ModulesRegistry.d.ts +0 -93
- package/build/src/runtime/modules/ModulesRegistry.js +0 -69
- package/build/src/runtime/modules/ModulesRegistry.js.map +0 -1
- package/build/src/runtime/modules/RequestAuthorization.d.ts +0 -6
- package/build/src/runtime/modules/RequestAuthorization.js +0 -110
- package/build/src/runtime/modules/RequestAuthorization.js.map +0 -1
- package/build/src/runtime/modules/RequestCookies.d.ts +0 -17
- package/build/src/runtime/modules/RequestCookies.js +0 -134
- package/build/src/runtime/modules/RequestCookies.js.map +0 -1
- package/build/src/runtime/node/RequestFactory.js +0 -406
- package/build/src/runtime/node/RequestFactory.js.map +0 -1
- package/build/src/runtime/node/VariablesStore.d.ts +0 -9
- package/build/src/runtime/node/VariablesStore.js +0 -19
- package/build/src/runtime/node/VariablesStore.js.map +0 -1
- package/src/lib/cookies/Cookie.ts +0 -312
- package/src/lib/cookies/Cookies.ts +0 -326
- package/src/lib/cookies/Utils.ts +0 -168
- package/src/mocking/lib/Arc.ts +0 -28
- package/src/models/RequestActions.ts +0 -161
- package/src/models/actions/Action.ts +0 -213
- package/src/models/actions/ActionView.ts +0 -40
- package/src/models/actions/Condition.ts +0 -207
- package/src/models/actions/ConditionView.ts +0 -42
- package/src/models/actions/Enums.ts +0 -29
- package/src/models/actions/RunnableAction.ts +0 -144
- package/src/models/actions/runnable/DeleteCookieAction.ts +0 -113
- package/src/models/actions/runnable/Runnable.ts +0 -9
- package/src/models/actions/runnable/SetCookieAction.ts +0 -216
- package/src/models/actions/runnable/SetVariableAction.ts +0 -81
- package/src/models/arc/ArcHttpRequest.ts +0 -129
- package/src/models/arc/readme.md +0 -3
- package/src/runtime/actions/ActionRunner.ts +0 -83
- package/src/runtime/actions/RunnableCondition.ts +0 -56
- package/src/runtime/actions/runnable/ActionRunnable.ts +0 -19
- package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +0 -39
- package/src/runtime/actions/runnable/SetCookieRunnable.ts +0 -92
- package/src/runtime/actions/runnable/SetVariableRunnable.ts +0 -53
- package/src/runtime/modules/BasicAuthCache.ts +0 -129
- package/src/runtime/modules/ExecutionResponse.ts +0 -4
- package/src/runtime/modules/ModulesRegistry.ts +0 -136
- package/src/runtime/modules/RequestAuthorization.ts +0 -106
- package/src/runtime/modules/RequestCookies.ts +0 -146
- package/src/runtime/node/RequestFactory.ts +0 -432
- package/src/runtime/node/VariablesStore.ts +0 -25
|
@@ -0,0 +1,629 @@
|
|
|
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, 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> {
|
|
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 a 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;
|
|
113
|
+
try {
|
|
114
|
+
data = JSON.parse(result.body).data;
|
|
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: IListResponse<IAppRequest | undefined>;
|
|
152
|
+
try {
|
|
153
|
+
data = JSON.parse(result.body);
|
|
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 a 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 a app request. ';
|
|
300
|
+
if (result.status !== 204) {
|
|
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
|
+
return { key };
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* SDK for the Application projects.
|
|
315
|
+
*/
|
|
316
|
+
export class AppProjectsSdk extends SdkBase {
|
|
317
|
+
/**
|
|
318
|
+
* Adds a single project to the app.
|
|
319
|
+
*
|
|
320
|
+
* @param value The project to add.
|
|
321
|
+
* @param appId The application id for which to create the project.
|
|
322
|
+
* @param request Optional request options
|
|
323
|
+
* @returns The created project with updated server-side properties.
|
|
324
|
+
*/
|
|
325
|
+
async create(value: IAppProject | AppProject, appId: string, request: ISdkRequestOptions = {}): Promise<IAppProject> {
|
|
326
|
+
if (!value) {
|
|
327
|
+
throw new Error(`Expected a value when inserting an app project.`);
|
|
328
|
+
}
|
|
329
|
+
const token = request.token || this.sdk.token;
|
|
330
|
+
const url = this.sdk.getUrl(RouteBuilder.appProjects(appId));
|
|
331
|
+
const body = JSON.stringify(value);
|
|
332
|
+
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
333
|
+
this.inspectCommonStatusCodes(result.status);
|
|
334
|
+
const E_PREFIX = 'Unable to create the app project. ';
|
|
335
|
+
if (result.status !== 200) {
|
|
336
|
+
this.logInvalidResponse(result);
|
|
337
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
338
|
+
}
|
|
339
|
+
if (!result.body) {
|
|
340
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
341
|
+
}
|
|
342
|
+
let data: IAppProject;
|
|
343
|
+
try {
|
|
344
|
+
data = JSON.parse(result.body);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
347
|
+
}
|
|
348
|
+
if (data.kind !== AppProjectKind) {
|
|
349
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
350
|
+
}
|
|
351
|
+
return data;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Lists application projects.
|
|
356
|
+
*
|
|
357
|
+
* @param appId The application id to which lists the projects.
|
|
358
|
+
* @param options List query options.
|
|
359
|
+
* @param request Optional request options
|
|
360
|
+
* @returns The list response with `AppProject`s
|
|
361
|
+
*/
|
|
362
|
+
async list(appId: string, options?: IListOptions, request: ISdkRequestOptions = {}): Promise<IListResponse<IAppProject>> {
|
|
363
|
+
const token = request.token || this.sdk.token;
|
|
364
|
+
const url = this.sdk.getUrl(RouteBuilder.appProjects(appId));
|
|
365
|
+
this.sdk.appendListOptions(url, options);
|
|
366
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
367
|
+
this.inspectCommonStatusCodes(result.status);
|
|
368
|
+
const E_PREFIX = 'Unable to list app project. ';
|
|
369
|
+
if (result.status !== 200) {
|
|
370
|
+
this.logInvalidResponse(result);
|
|
371
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
372
|
+
}
|
|
373
|
+
if (!result.body) {
|
|
374
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
375
|
+
}
|
|
376
|
+
let data: IListResponse<IAppProject>;
|
|
377
|
+
try {
|
|
378
|
+
data = JSON.parse(result.body);
|
|
379
|
+
} catch (e) {
|
|
380
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
381
|
+
}
|
|
382
|
+
if (!Array.isArray(data.items)) {
|
|
383
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
384
|
+
}
|
|
385
|
+
return data;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Creates a number of `AppProject`s in a batch operation.
|
|
390
|
+
*
|
|
391
|
+
* @param values The `AppProject`s list to insert.
|
|
392
|
+
* @param appId The application id generating these projects.
|
|
393
|
+
* @param request Optional request options
|
|
394
|
+
* @returns The ordered list of created projects.
|
|
395
|
+
*/
|
|
396
|
+
async createBatch(values: (IAppProject | AppProject)[], appId: string, request: ISdkRequestOptions = {}): Promise<IBatchUpdateResult> {
|
|
397
|
+
if (!Array.isArray(values)) {
|
|
398
|
+
throw new Error(`Expected a value when inserting app project list.`);
|
|
399
|
+
}
|
|
400
|
+
const token = request.token || this.sdk.token;
|
|
401
|
+
const url = this.sdk.getUrl(RouteBuilder.appProjectsBatchCreate(appId));
|
|
402
|
+
const content: IBatchUpdate = {
|
|
403
|
+
items: values,
|
|
404
|
+
};
|
|
405
|
+
const body = JSON.stringify(content);
|
|
406
|
+
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
407
|
+
this.inspectCommonStatusCodes(result.status);
|
|
408
|
+
const E_PREFIX = 'Unable to create a app project in bulk. ';
|
|
409
|
+
if (result.status !== 200) {
|
|
410
|
+
this.logInvalidResponse(result);
|
|
411
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
412
|
+
}
|
|
413
|
+
if (!result.body) {
|
|
414
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
415
|
+
}
|
|
416
|
+
let data: IBatchUpdateResult;
|
|
417
|
+
try {
|
|
418
|
+
data = JSON.parse(result.body).data;
|
|
419
|
+
} catch (e) {
|
|
420
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
421
|
+
}
|
|
422
|
+
if (!Array.isArray(data.items)) {
|
|
423
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
424
|
+
}
|
|
425
|
+
return data;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Reads `AppProject`s in a batch operation.
|
|
430
|
+
*
|
|
431
|
+
* @param keys The list of project keys to read.
|
|
432
|
+
* @param appId The application id that generated the app projects.
|
|
433
|
+
* @param request Optional HTTP request options
|
|
434
|
+
* @returns The ordered list of results. The undefined/null value means the object couldn't be read (does not exists or no access).
|
|
435
|
+
*/
|
|
436
|
+
async readBatch(keys: string[], appId: string, request: ISdkRequestOptions = {}): Promise<IBatchReadResult<IAppProject>> {
|
|
437
|
+
const token = request.token || this.sdk.token;
|
|
438
|
+
const url = this.sdk.getUrl(RouteBuilder.appProjectsBatchRead(appId));
|
|
439
|
+
const body = JSON.stringify(keys);
|
|
440
|
+
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
441
|
+
this.inspectCommonStatusCodes(result.status, result.body);
|
|
442
|
+
const E_PREFIX = 'Unable to read app project in bulk. ';
|
|
443
|
+
if (result.status !== 200) {
|
|
444
|
+
this.logInvalidResponse(result);
|
|
445
|
+
let e = this.createGenericSdkError(result.body)
|
|
446
|
+
if (!e) {
|
|
447
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
448
|
+
e.response = result.body;
|
|
449
|
+
}
|
|
450
|
+
throw e;
|
|
451
|
+
}
|
|
452
|
+
if (!result.body) {
|
|
453
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
454
|
+
}
|
|
455
|
+
let data: IListResponse<IAppProject | undefined>;
|
|
456
|
+
try {
|
|
457
|
+
data = JSON.parse(result.body);
|
|
458
|
+
} catch (e) {
|
|
459
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
460
|
+
}
|
|
461
|
+
if (!Array.isArray(data.items)) {
|
|
462
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
463
|
+
}
|
|
464
|
+
return data;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Deletes `AppProject`s in a batch operation.
|
|
469
|
+
*
|
|
470
|
+
* @param keys The list of project keys to delete.
|
|
471
|
+
* @param appId The application id that generated the app projects.
|
|
472
|
+
* @param request Optional HTTP request options
|
|
473
|
+
* @returns A delete record for each project or null/undefined when couldn't delete the record.
|
|
474
|
+
*/
|
|
475
|
+
async deleteBatch(keys: string[], appId: string, request: ISdkRequestOptions = {}): Promise<IBatchDeleteResult> {
|
|
476
|
+
const token = request.token || this.sdk.token;
|
|
477
|
+
const url = this.sdk.getUrl(RouteBuilder.appProjectsBatchDelete(appId));
|
|
478
|
+
const body = JSON.stringify(keys);
|
|
479
|
+
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
480
|
+
this.inspectCommonStatusCodes(result.status, result.body);
|
|
481
|
+
const E_PREFIX = 'Unable to delete a app project in bulk. ';
|
|
482
|
+
if (result.status !== 200) {
|
|
483
|
+
this.logInvalidResponse(result);
|
|
484
|
+
let e = this.createGenericSdkError(result.body)
|
|
485
|
+
if (!e) {
|
|
486
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
487
|
+
e.response = result.body;
|
|
488
|
+
}
|
|
489
|
+
throw e;
|
|
490
|
+
}
|
|
491
|
+
if (!result.body) {
|
|
492
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
493
|
+
}
|
|
494
|
+
let data: IBatchDeleteResult;
|
|
495
|
+
try {
|
|
496
|
+
data = JSON.parse(result.body);
|
|
497
|
+
} catch (e) {
|
|
498
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
499
|
+
}
|
|
500
|
+
if (!Array.isArray(data.items)) {
|
|
501
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
502
|
+
}
|
|
503
|
+
return data;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Restores previously deleted `AppProject`s.
|
|
508
|
+
*
|
|
509
|
+
* @param keys The list of keys of deleted records.
|
|
510
|
+
* @param appId The application id that generated the app projects.
|
|
511
|
+
* @param request Optional HTTP request options
|
|
512
|
+
* @returns The ordered list of the restored projects. An item can be null/undefined when the service couldn't restore the project.
|
|
513
|
+
*/
|
|
514
|
+
async undeleteBatch(keys: string[], appId: string, request: ISdkRequestOptions = {}): Promise<IRevertResponse<IAppProject>> {
|
|
515
|
+
if (!keys) {
|
|
516
|
+
throw new Error(`The "records" argument is missing.`);
|
|
517
|
+
}
|
|
518
|
+
if (!Array.isArray(keys)) {
|
|
519
|
+
throw new Error(`The "records" argument expected to be an array.`);
|
|
520
|
+
}
|
|
521
|
+
const token = request.token || this.sdk.token;
|
|
522
|
+
const url = this.sdk.getUrl(RouteBuilder.appProjectsBatchUndelete(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 restore 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: IRevertResponse<IAppProject>;
|
|
540
|
+
try {
|
|
541
|
+
data = JSON.parse(result.body);
|
|
542
|
+
} catch (e) {
|
|
543
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
544
|
+
}
|
|
545
|
+
if (!Array.isArray(data.items)) {
|
|
546
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
547
|
+
}
|
|
548
|
+
return data;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Reads a single AppProject entry from the store.
|
|
553
|
+
*
|
|
554
|
+
* @param key The key of the project to read.
|
|
555
|
+
* @param appId The application id that created this entry.
|
|
556
|
+
* @param request Optional request options
|
|
557
|
+
* @returns The stored AppProject.
|
|
558
|
+
*/
|
|
559
|
+
async read(key: string, appId: string, request: ISdkRequestOptions = {}): Promise<IAppProject> {
|
|
560
|
+
const token = request.token || this.sdk.token;
|
|
561
|
+
const url = this.sdk.getUrl(RouteBuilder.appProjectItem(appId, key));
|
|
562
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
563
|
+
this.inspectCommonStatusCodes(result.status, result.body);
|
|
564
|
+
const E_PREFIX = 'Unable to read app project. ';
|
|
565
|
+
if (result.status !== 200) {
|
|
566
|
+
this.logInvalidResponse(result);
|
|
567
|
+
let e = this.createGenericSdkError(result.body)
|
|
568
|
+
if (!e) {
|
|
569
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
570
|
+
e.response = result.body;
|
|
571
|
+
}
|
|
572
|
+
throw e;
|
|
573
|
+
}
|
|
574
|
+
if (!result.body) {
|
|
575
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
576
|
+
}
|
|
577
|
+
let data: IAppProject;
|
|
578
|
+
try {
|
|
579
|
+
data = JSON.parse(result.body);
|
|
580
|
+
} catch (e) {
|
|
581
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
582
|
+
}
|
|
583
|
+
if (data.kind !== AppProjectKind) {
|
|
584
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
585
|
+
}
|
|
586
|
+
return data;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Deletes a single `AppProject`.
|
|
591
|
+
*
|
|
592
|
+
* @param key The key of the `AppProject` to delete.
|
|
593
|
+
* @param appId The application id that created this entry.
|
|
594
|
+
* @param request Optional request options
|
|
595
|
+
* @returns The delete record for the project.
|
|
596
|
+
*/
|
|
597
|
+
async delete(key: string, appId: string, request: ISdkRequestOptions = {}): Promise<IDeleteRecord> {
|
|
598
|
+
const token = request.token || this.sdk.token;
|
|
599
|
+
const url = this.sdk.getUrl(RouteBuilder.appProjectItem(appId, key));
|
|
600
|
+
url.searchParams.set('appId', appId);
|
|
601
|
+
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
602
|
+
this.inspectCommonStatusCodes(result.status, result.body);
|
|
603
|
+
const E_PREFIX = 'Unable to delete a app project. ';
|
|
604
|
+
if (result.status !== 204) {
|
|
605
|
+
this.logInvalidResponse(result);
|
|
606
|
+
let e = this.createGenericSdkError(result.body)
|
|
607
|
+
if (!e) {
|
|
608
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
609
|
+
e.response = result.body;
|
|
610
|
+
}
|
|
611
|
+
throw e;
|
|
612
|
+
}
|
|
613
|
+
return { key };
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Sdk used by the HTTP Client.
|
|
619
|
+
*/
|
|
620
|
+
export class AppSdk extends SdkBase {
|
|
621
|
+
requests: AppRequestsSdk;
|
|
622
|
+
projects: AppProjectsSdk;
|
|
623
|
+
|
|
624
|
+
constructor(sdk: Sdk) {
|
|
625
|
+
super(sdk);
|
|
626
|
+
this.requests = new AppRequestsSdk(sdk);
|
|
627
|
+
this.projects = new AppProjectsSdk(sdk);
|
|
628
|
+
}
|
|
629
|
+
}
|