windmill-client 0.3.10 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +120 -155
- package/dist/core/CancelablePromise.js +3 -6
- package/dist/core/request.d.ts +0 -4
- package/dist/core/request.js +47 -43
- package/dist/index.js +42 -42
- package/dist/services/AdminService.js +2 -2
- package/dist/services/AppService.js +2 -2
- package/dist/services/AuditService.js +2 -2
- package/dist/services/CaptureService.js +2 -2
- package/dist/services/DraftService.js +2 -2
- package/dist/services/FavoriteService.js +2 -2
- package/dist/services/FlowService.js +2 -2
- package/dist/services/FolderService.js +2 -2
- package/dist/services/GranularAclService.js +2 -2
- package/dist/services/GroupService.js +2 -2
- package/dist/services/InputService.js +2 -2
- package/dist/services/JobService.js +2 -2
- package/dist/services/OauthService.js +2 -2
- package/dist/services/RawAppService.js +2 -2
- package/dist/services/ResourceService.js +2 -2
- package/dist/services/ScheduleService.js +2 -2
- package/dist/services/ScriptService.js +2 -2
- package/dist/services/SettingsService.js +2 -2
- package/dist/services/UserService.js +2 -2
- package/dist/services/VariableService.js +2 -2
- package/dist/services/WorkerService.js +2 -2
- package/dist/services/WorkspaceService.js +2 -2
- package/dist/src/client.d.ts +77 -0
- package/dist/src/client.js +301 -0
- package/dist/src/core/ApiError.d.ts +10 -0
- package/dist/src/core/ApiError.js +11 -0
- package/dist/src/core/ApiRequestOptions.d.ts +13 -0
- package/dist/src/core/ApiRequestOptions.js +1 -0
- package/dist/src/core/ApiResult.d.ts +7 -0
- package/dist/src/core/ApiResult.js +1 -0
- package/dist/src/core/CancelablePromise.d.ts +20 -0
- package/dist/src/core/CancelablePromise.js +108 -0
- package/dist/src/core/OpenAPI.d.ts +16 -0
- package/dist/src/core/OpenAPI.js +11 -0
- package/dist/src/core/request.d.ts +30 -0
- package/dist/src/core/request.js +274 -0
- package/dist/src/index.d.ts +143 -0
- package/dist/src/index.js +46 -0
- package/dist/src/models/AccountId.d.ts +1 -0
- package/dist/src/models/AccountId.js +5 -0
- package/dist/src/models/ActionKind.d.ts +9 -0
- package/dist/src/models/ActionKind.js +14 -0
- package/dist/src/models/After.d.ts +4 -0
- package/dist/src/models/After.js +5 -0
- package/dist/src/models/AppWithLastVersion.d.ts +21 -0
- package/dist/src/models/AppWithLastVersion.js +13 -0
- package/dist/src/models/AppWithLastVersionWDraft.d.ts +5 -0
- package/dist/src/models/AppWithLastVersionWDraft.js +5 -0
- package/dist/src/models/ArgsFilter.d.ts +4 -0
- package/dist/src/models/ArgsFilter.js +5 -0
- package/dist/src/models/AuditLog.d.ts +32 -0
- package/dist/src/models/AuditLog.js +30 -0
- package/dist/src/models/Before.d.ts +4 -0
- package/dist/src/models/Before.js +5 -0
- package/dist/src/models/BranchAll.d.ts +10 -0
- package/dist/src/models/BranchAll.js +5 -0
- package/dist/src/models/BranchOne.d.ts +10 -0
- package/dist/src/models/BranchOne.js +5 -0
- package/dist/src/models/ClientName.d.ts +1 -0
- package/dist/src/models/ClientName.js +5 -0
- package/dist/src/models/CompletedJob.d.ts +61 -0
- package/dist/src/models/CompletedJob.js +28 -0
- package/dist/src/models/ContextualVariable.d.ts +5 -0
- package/dist/src/models/ContextualVariable.js +5 -0
- package/dist/src/models/CreateInput.d.ts +4 -0
- package/dist/src/models/CreateInput.js +5 -0
- package/dist/src/models/CreateResource.d.ts +6 -0
- package/dist/src/models/CreateResource.js +5 -0
- package/dist/src/models/CreateVariable.d.ts +8 -0
- package/dist/src/models/CreateVariable.js +5 -0
- package/dist/src/models/CreateWorkspace.d.ts +5 -0
- package/dist/src/models/CreateWorkspace.js +5 -0
- package/dist/src/models/CreatedBy.d.ts +4 -0
- package/dist/src/models/CreatedBy.js +5 -0
- package/dist/src/models/EditResource.d.ts +5 -0
- package/dist/src/models/EditResource.js +5 -0
- package/dist/src/models/EditResourceType.d.ts +4 -0
- package/dist/src/models/EditResourceType.js +5 -0
- package/dist/src/models/EditSchedule.d.ts +7 -0
- package/dist/src/models/EditSchedule.js +5 -0
- package/dist/src/models/EditVariable.d.ts +6 -0
- package/dist/src/models/EditVariable.js +5 -0
- package/dist/src/models/EditWorkspaceUser.d.ts +5 -0
- package/dist/src/models/EditWorkspaceUser.js +5 -0
- package/dist/src/models/Flow.d.ts +3 -0
- package/dist/src/models/Flow.js +5 -0
- package/dist/src/models/FlowMetadata.d.ts +11 -0
- package/dist/src/models/FlowMetadata.js +5 -0
- package/dist/src/models/FlowModule.d.ts +26 -0
- package/dist/src/models/FlowModule.js +5 -0
- package/dist/src/models/FlowModuleValue.d.ts +10 -0
- package/dist/src/models/FlowModuleValue.js +5 -0
- package/dist/src/models/FlowPreview.d.ts +7 -0
- package/dist/src/models/FlowPreview.js +5 -0
- package/dist/src/models/FlowStatus.d.ts +12 -0
- package/dist/src/models/FlowStatus.js +5 -0
- package/dist/src/models/FlowStatusModule.d.ts +34 -0
- package/dist/src/models/FlowStatusModule.js +16 -0
- package/dist/src/models/FlowValue.d.ts +6 -0
- package/dist/src/models/FlowValue.js +5 -0
- package/dist/src/models/Folder.d.ts +5 -0
- package/dist/src/models/Folder.js +5 -0
- package/dist/src/models/ForloopFlow.d.ts +9 -0
- package/dist/src/models/ForloopFlow.js +5 -0
- package/dist/src/models/GlobalUserInfo.d.ts +14 -0
- package/dist/src/models/GlobalUserInfo.js +12 -0
- package/dist/src/models/Graphql.d.ts +3 -0
- package/dist/src/models/Graphql.js +5 -0
- package/dist/src/models/Group.d.ts +6 -0
- package/dist/src/models/Group.js +5 -0
- package/dist/src/models/Http.d.ts +3 -0
- package/dist/src/models/Http.js +5 -0
- package/dist/src/models/Identity.d.ts +4 -0
- package/dist/src/models/Identity.js +5 -0
- package/dist/src/models/IncludeHeader.d.ts +6 -0
- package/dist/src/models/IncludeHeader.js +5 -0
- package/dist/src/models/Input.d.ts +8 -0
- package/dist/src/models/Input.js +5 -0
- package/dist/src/models/InputId.d.ts +1 -0
- package/dist/src/models/InputId.js +5 -0
- package/dist/src/models/InputTransform.d.ts +3 -0
- package/dist/src/models/InputTransform.js +5 -0
- package/dist/src/models/JavascriptTransform.d.ts +4 -0
- package/dist/src/models/JavascriptTransform.js +5 -0
- package/dist/src/models/Job.d.ts +11 -0
- package/dist/src/models/Job.js +12 -0
- package/dist/src/models/JobId.d.ts +1 -0
- package/dist/src/models/JobId.js +5 -0
- package/dist/src/models/JobKinds.d.ts +4 -0
- package/dist/src/models/JobKinds.js +5 -0
- package/dist/src/models/ListableApp.d.ts +18 -0
- package/dist/src/models/ListableApp.js +13 -0
- package/dist/src/models/ListableRawApp.d.ts +9 -0
- package/dist/src/models/ListableRawApp.js +5 -0
- package/dist/src/models/ListableResource.d.ts +14 -0
- package/dist/src/models/ListableResource.js +5 -0
- package/dist/src/models/ListableVariable.d.ts +14 -0
- package/dist/src/models/ListableVariable.js +5 -0
- package/dist/src/models/Login.d.ts +4 -0
- package/dist/src/models/Login.js +5 -0
- package/dist/src/models/MainArgSignature.d.ts +33 -0
- package/dist/src/models/MainArgSignature.js +12 -0
- package/dist/src/models/Name.d.ts +1 -0
- package/dist/src/models/Name.js +5 -0
- package/dist/src/models/NewJobId.d.ts +4 -0
- package/dist/src/models/NewJobId.js +5 -0
- package/dist/src/models/NewSchedule.d.ts +11 -0
- package/dist/src/models/NewSchedule.js +5 -0
- package/dist/src/models/NewScript.d.ts +33 -0
- package/dist/src/models/NewScript.js +25 -0
- package/dist/src/models/NewScriptWithDraft.d.ts +5 -0
- package/dist/src/models/NewScriptWithDraft.js +5 -0
- package/dist/src/models/NewToken.d.ts +5 -0
- package/dist/src/models/NewToken.js +5 -0
- package/dist/src/models/NewTokenImpersonate.d.ts +5 -0
- package/dist/src/models/NewTokenImpersonate.js +5 -0
- package/dist/src/models/NewUser.d.ts +5 -0
- package/dist/src/models/NewUser.js +5 -0
- package/dist/src/models/OpenFlow.d.ts +7 -0
- package/dist/src/models/OpenFlow.js +5 -0
- package/dist/src/models/OpenFlowWPath.d.ts +4 -0
- package/dist/src/models/OpenFlowWPath.js +5 -0
- package/dist/src/models/Operation.d.ts +4 -0
- package/dist/src/models/Operation.js +5 -0
- package/dist/src/models/OrderDesc.d.ts +4 -0
- package/dist/src/models/OrderDesc.js +5 -0
- package/dist/src/models/Page.d.ts +4 -0
- package/dist/src/models/Page.js +5 -0
- package/dist/src/models/ParentJob.d.ts +4 -0
- package/dist/src/models/ParentJob.js +5 -0
- package/dist/src/models/Path.d.ts +1 -0
- package/dist/src/models/Path.js +5 -0
- package/dist/src/models/PathFlow.d.ts +6 -0
- package/dist/src/models/PathFlow.js +5 -0
- package/dist/src/models/PathId.d.ts +1 -0
- package/dist/src/models/PathId.js +5 -0
- package/dist/src/models/PathScript.d.ts +7 -0
- package/dist/src/models/PathScript.js +5 -0
- package/dist/src/models/Payload.d.ts +6 -0
- package/dist/src/models/Payload.js +5 -0
- package/dist/src/models/PerPage.d.ts +4 -0
- package/dist/src/models/PerPage.js +5 -0
- package/dist/src/models/Policy.d.ts +13 -0
- package/dist/src/models/Policy.js +13 -0
- package/dist/src/models/Preview.d.ts +25 -0
- package/dist/src/models/Preview.js +23 -0
- package/dist/src/models/QueueLimit.d.ts +5 -0
- package/dist/src/models/QueueLimit.js +5 -0
- package/dist/src/models/QueuedJob.d.ts +59 -0
- package/dist/src/models/QueuedJob.js +28 -0
- package/dist/src/models/RawScript.d.ts +20 -0
- package/dist/src/models/RawScript.js +16 -0
- package/dist/src/models/Resource.d.ts +9 -0
- package/dist/src/models/Resource.js +5 -0
- package/dist/src/models/ResourceName.d.ts +4 -0
- package/dist/src/models/ResourceName.js +5 -0
- package/dist/src/models/ResourceType.d.ts +6 -0
- package/dist/src/models/ResourceType.js +5 -0
- package/dist/src/models/ResultFilter.d.ts +4 -0
- package/dist/src/models/ResultFilter.js +5 -0
- package/dist/src/models/Retry.d.ts +11 -0
- package/dist/src/models/Retry.js +5 -0
- package/dist/src/models/RunnableId.d.ts +1 -0
- package/dist/src/models/RunnableId.js +5 -0
- package/dist/src/models/RunnableType.d.ts +5 -0
- package/dist/src/models/RunnableType.js +10 -0
- package/dist/src/models/RunnableTypeQuery.d.ts +2 -0
- package/dist/src/models/RunnableTypeQuery.js +5 -0
- package/dist/src/models/Running.d.ts +4 -0
- package/dist/src/models/Running.js +5 -0
- package/dist/src/models/Schedule.d.ts +16 -0
- package/dist/src/models/Schedule.js +5 -0
- package/dist/src/models/SchedulePath.d.ts +4 -0
- package/dist/src/models/SchedulePath.js +5 -0
- package/dist/src/models/ScheduleWJobs.d.ts +8 -0
- package/dist/src/models/ScheduleWJobs.js +5 -0
- package/dist/src/models/Script.d.ts +47 -0
- package/dist/src/models/Script.js +25 -0
- package/dist/src/models/ScriptArgs.d.ts +1 -0
- package/dist/src/models/ScriptArgs.js +5 -0
- package/dist/src/models/ScriptExactHash.d.ts +4 -0
- package/dist/src/models/ScriptExactHash.js +5 -0
- package/dist/src/models/ScriptExactPath.d.ts +4 -0
- package/dist/src/models/ScriptExactPath.js +5 -0
- package/dist/src/models/ScriptHash.d.ts +1 -0
- package/dist/src/models/ScriptHash.js +5 -0
- package/dist/src/models/ScriptPath.d.ts +1 -0
- package/dist/src/models/ScriptPath.js +5 -0
- package/dist/src/models/ScriptStartPath.d.ts +4 -0
- package/dist/src/models/ScriptStartPath.js +5 -0
- package/dist/src/models/SlackToken.d.ts +8 -0
- package/dist/src/models/SlackToken.js +5 -0
- package/dist/src/models/StartedAfter.d.ts +4 -0
- package/dist/src/models/StartedAfter.js +5 -0
- package/dist/src/models/StartedBefore.d.ts +4 -0
- package/dist/src/models/StartedBefore.js +5 -0
- package/dist/src/models/StaticTransform.d.ts +4 -0
- package/dist/src/models/StaticTransform.js +5 -0
- package/dist/src/models/Success.d.ts +4 -0
- package/dist/src/models/Success.js +5 -0
- package/dist/src/models/Suspended.d.ts +4 -0
- package/dist/src/models/Suspended.js +5 -0
- package/dist/src/models/Tag.d.ts +4 -0
- package/dist/src/models/Tag.js +5 -0
- package/dist/src/models/Token.d.ts +1 -0
- package/dist/src/models/Token.js +5 -0
- package/dist/src/models/TokenResponse.d.ts +6 -0
- package/dist/src/models/TokenResponse.js +5 -0
- package/dist/src/models/TruncatedToken.d.ts +8 -0
- package/dist/src/models/TruncatedToken.js +5 -0
- package/dist/src/models/UpdateInput.d.ts +5 -0
- package/dist/src/models/UpdateInput.js +5 -0
- package/dist/src/models/Usage.d.ts +3 -0
- package/dist/src/models/Usage.js +5 -0
- package/dist/src/models/User.d.ts +14 -0
- package/dist/src/models/User.js +5 -0
- package/dist/src/models/UserWorkspaceList.d.ts +8 -0
- package/dist/src/models/UserWorkspaceList.js +5 -0
- package/dist/src/models/Username.d.ts +4 -0
- package/dist/src/models/Username.js +5 -0
- package/dist/src/models/VersionId.d.ts +1 -0
- package/dist/src/models/VersionId.js +5 -0
- package/dist/src/models/WorkerPing.d.ts +8 -0
- package/dist/src/models/WorkerPing.js +5 -0
- package/dist/src/models/Workspace.d.ts +6 -0
- package/dist/src/models/Workspace.js +5 -0
- package/dist/src/models/WorkspaceId.d.ts +1 -0
- package/dist/src/models/WorkspaceId.js +5 -0
- package/dist/src/models/WorkspaceInvite.d.ts +6 -0
- package/dist/src/models/WorkspaceInvite.js +5 -0
- package/dist/src/services/AdminService.d.ts +39 -0
- package/dist/src/services/AdminService.js +52 -0
- package/dist/src/services/AppService.d.ts +195 -0
- package/dist/src/services/AppService.js +207 -0
- package/dist/src/services/AuditService.d.ts +53 -0
- package/dist/src/services/AuditService.js +43 -0
- package/dist/src/services/CaptureService.d.ts +30 -0
- package/dist/src/services/CaptureService.js +52 -0
- package/dist/src/services/DraftService.d.ts +26 -0
- package/dist/src/services/DraftService.js +36 -0
- package/dist/src/services/FavoriteService.d.ts +27 -0
- package/dist/src/services/FavoriteService.js +36 -0
- package/dist/src/services/FlowService.d.ts +186 -0
- package/dist/src/services/FlowService.js +196 -0
- package/dist/src/services/FolderService.d.ts +128 -0
- package/dist/src/services/FolderService.js +151 -0
- package/dist/src/services/GranularAclService.d.ts +46 -0
- package/dist/src/services/GranularAclService.js +56 -0
- package/dist/src/services/GroupService.d.ts +110 -0
- package/dist/src/services/GroupService.js +136 -0
- package/dist/src/services/InputService.d.ts +78 -0
- package/dist/src/services/InputService.js +95 -0
- package/dist/src/services/JobService.d.ts +761 -0
- package/dist/src/services/JobService.js +646 -0
- package/dist/src/services/OauthService.d.ts +95 -0
- package/dist/src/services/OauthService.js +120 -0
- package/dist/src/services/RawAppService.d.ts +103 -0
- package/dist/src/services/RawAppService.js +106 -0
- package/dist/src/services/ResourceService.d.ts +178 -0
- package/dist/src/services/ResourceService.js +243 -0
- package/dist/src/services/ScheduleService.d.ts +120 -0
- package/dist/src/services/ScheduleService.js +148 -0
- package/dist/src/services/ScriptService.d.ts +258 -0
- package/dist/src/services/ScriptService.js +283 -0
- package/dist/src/services/SettingsService.d.ts +27 -0
- package/dist/src/services/SettingsService.js +48 -0
- package/dist/src/services/UserService.d.ts +306 -0
- package/dist/src/services/UserService.js +397 -0
- package/dist/src/services/VariableService.d.ts +95 -0
- package/dist/src/services/VariableService.js +135 -0
- package/dist/src/services/WorkerService.d.ts +25 -0
- package/dist/src/services/WorkerService.js +30 -0
- package/dist/src/services/WorkspaceService.d.ts +249 -0
- package/dist/src/services/WorkspaceService.js +301 -0
- package/package.json +5 -3
package/dist/client.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { ResourceService, VariableService } from "./index";
|
|
11
|
-
import { OpenAPI } from "./index";
|
|
12
|
-
export { AdminService, AuditService, FlowService, GranularAclService, GroupService, JobService, ResourceService, VariableService, ScriptService, ScheduleService, SettingsService, UserService, WorkspaceService, } from "./index";
|
|
1
|
+
import { ResourceService, VariableService } from "./index.js";
|
|
2
|
+
import { OpenAPI } from "./index.js";
|
|
3
|
+
export { AdminService, AuditService, FlowService, GranularAclService, GroupService, JobService, ResourceService, VariableService, ScriptService, ScheduleService, SettingsService, UserService, WorkspaceService, } from "./index.js";
|
|
13
4
|
export const SHARED_FOLDER = "/shared";
|
|
14
5
|
export function setClient(token, baseUrl) {
|
|
15
|
-
var _a, _b, _c;
|
|
16
6
|
if (baseUrl === undefined) {
|
|
17
7
|
baseUrl =
|
|
18
|
-
|
|
8
|
+
getEnv("BASE_INTERNAL_URL") ??
|
|
9
|
+
getEnv("BASE_URL") ??
|
|
10
|
+
"http://localhost:8000";
|
|
19
11
|
}
|
|
20
12
|
if (token === undefined) {
|
|
21
|
-
|
|
13
|
+
token = getEnv("WM_TOKEN") ?? "no_token";
|
|
22
14
|
}
|
|
23
15
|
OpenAPI.WITH_CREDENTIALS = true;
|
|
24
16
|
OpenAPI.TOKEN = token;
|
|
@@ -37,8 +29,7 @@ const getEnv = (key) => {
|
|
|
37
29
|
* @returns client configuration
|
|
38
30
|
*/
|
|
39
31
|
export function getWorkspace() {
|
|
40
|
-
|
|
41
|
-
return (_a = getEnv("WM_WORKSPACE")) !== null && _a !== void 0 ? _a : "no_workspace";
|
|
32
|
+
return getEnv("WM_WORKSPACE") ?? "no_workspace";
|
|
42
33
|
}
|
|
43
34
|
/**
|
|
44
35
|
* Get a resource value by path
|
|
@@ -46,38 +37,34 @@ export function getWorkspace() {
|
|
|
46
37
|
* @param undefinedIfEmpty if the resource does not exist, return undefined instead of throwing an error
|
|
47
38
|
* @returns resource value
|
|
48
39
|
*/
|
|
49
|
-
export function getResource(path, undefinedIfEmpty) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
export async function getResource(path, undefinedIfEmpty) {
|
|
41
|
+
const workspace = getWorkspace();
|
|
42
|
+
path = path ?? getStatePath();
|
|
43
|
+
try {
|
|
44
|
+
const resource = await ResourceService.getResource({ workspace, path });
|
|
45
|
+
return await _transformLeaf(resource.value);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
if (undefinedIfEmpty && e.status === 404) {
|
|
49
|
+
return undefined;
|
|
56
50
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
throw Error(`Resource not found at ${path} or not visible to you`);
|
|
63
|
-
}
|
|
51
|
+
else {
|
|
52
|
+
throw Error(`Resource not found at ${path} or not visible to you`);
|
|
64
53
|
}
|
|
65
|
-
}
|
|
54
|
+
}
|
|
66
55
|
}
|
|
67
56
|
/**
|
|
68
57
|
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
|
69
58
|
* @param obj resource value or path of the resource under the format `$res:path`
|
|
70
59
|
* @returns resource value
|
|
71
60
|
*/
|
|
72
|
-
export function resolveDefaultResource(obj) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
});
|
|
61
|
+
export async function resolveDefaultResource(obj) {
|
|
62
|
+
if (typeof obj === "string" && obj.startsWith("$res:")) {
|
|
63
|
+
return await getResource(obj.substring(5), true);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
81
68
|
}
|
|
82
69
|
/**
|
|
83
70
|
* Get the full resource value by path
|
|
@@ -85,24 +72,22 @@ export function resolveDefaultResource(obj) {
|
|
|
85
72
|
* @param undefinedIfEmpty if the resource does not exist, return undefined instead of throwing an error
|
|
86
73
|
* @returns full resource
|
|
87
74
|
*/
|
|
88
|
-
export function getFullResource(path, undefinedIfEmpty) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
75
|
+
export async function getFullResource(path, undefinedIfEmpty) {
|
|
76
|
+
const workspace = getWorkspace();
|
|
77
|
+
path = path ?? getStatePath();
|
|
78
|
+
try {
|
|
79
|
+
const resource = await ResourceService.getResource({ workspace, path });
|
|
80
|
+
const value = await _transformLeaf(resource.value);
|
|
81
|
+
return { ...resource, value };
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
if (undefinedIfEmpty && e.status === 404) {
|
|
85
|
+
return undefined;
|
|
96
86
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
throw Error(`Resource not found at ${path} or not visible to you`);
|
|
103
|
-
}
|
|
87
|
+
else {
|
|
88
|
+
throw Error(`Resource not found at ${path} or not visible to you`);
|
|
104
89
|
}
|
|
105
|
-
}
|
|
90
|
+
}
|
|
106
91
|
}
|
|
107
92
|
export function getStatePath() {
|
|
108
93
|
const state_path = getEnv("WM_STATE_PATH");
|
|
@@ -117,46 +102,40 @@ export function getStatePath() {
|
|
|
117
102
|
* @param value new value of the resource to set
|
|
118
103
|
* @param initializeToTypeIfNotExist if the resource does not exist, initialize it with this type
|
|
119
104
|
*/
|
|
120
|
-
export function setResource(value, path, initializeToTypeIfNotExist) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
});
|
|
105
|
+
export async function setResource(value, path, initializeToTypeIfNotExist) {
|
|
106
|
+
path = path ?? getStatePath();
|
|
107
|
+
const workspace = getWorkspace();
|
|
108
|
+
if (await ResourceService.existsResource({ workspace, path })) {
|
|
109
|
+
await ResourceService.updateResourceValue({
|
|
110
|
+
workspace,
|
|
111
|
+
path,
|
|
112
|
+
requestBody: { value },
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
else if (initializeToTypeIfNotExist) {
|
|
116
|
+
await ResourceService.createResource({
|
|
117
|
+
workspace,
|
|
118
|
+
requestBody: { path, value, resource_type: initializeToTypeIfNotExist },
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw Error(`Resource at path ${path} does not exist and no type was provided to initialize it`);
|
|
123
|
+
}
|
|
141
124
|
}
|
|
142
125
|
/**
|
|
143
126
|
* Set the state
|
|
144
127
|
* @param state state to set
|
|
145
128
|
* @deprecated use setState instead
|
|
146
129
|
*/
|
|
147
|
-
export function setInternalState(state) {
|
|
148
|
-
|
|
149
|
-
yield setResource(state, undefined, "state");
|
|
150
|
-
});
|
|
130
|
+
export async function setInternalState(state) {
|
|
131
|
+
await setResource(state, undefined, "state");
|
|
151
132
|
}
|
|
152
133
|
/**
|
|
153
134
|
* Set the state
|
|
154
135
|
* @param state state to set
|
|
155
136
|
*/
|
|
156
|
-
export function setState(state) {
|
|
157
|
-
|
|
158
|
-
yield setResource(state, undefined, "state");
|
|
159
|
-
});
|
|
137
|
+
export async function setState(state) {
|
|
138
|
+
await setResource(state, undefined, "state");
|
|
160
139
|
}
|
|
161
140
|
// /**
|
|
162
141
|
// * Set the shared state
|
|
@@ -179,35 +158,29 @@ export function setState(state) {
|
|
|
179
158
|
* Get the internal state
|
|
180
159
|
* @deprecated use getState instead
|
|
181
160
|
*/
|
|
182
|
-
export function getInternalState() {
|
|
183
|
-
return
|
|
184
|
-
return yield getResource(getStatePath(), true);
|
|
185
|
-
});
|
|
161
|
+
export async function getInternalState() {
|
|
162
|
+
return await getResource(getStatePath(), true);
|
|
186
163
|
}
|
|
187
164
|
/**
|
|
188
165
|
* Get the state shared across executions
|
|
189
166
|
*/
|
|
190
|
-
export function getState() {
|
|
191
|
-
return
|
|
192
|
-
return yield getResource(getStatePath(), true);
|
|
193
|
-
});
|
|
167
|
+
export async function getState() {
|
|
168
|
+
return await getResource(getStatePath(), true);
|
|
194
169
|
}
|
|
195
170
|
/**
|
|
196
171
|
* Get a variable by path
|
|
197
172
|
* @param path path of the variable
|
|
198
173
|
* @returns variable value
|
|
199
174
|
*/
|
|
200
|
-
export function getVariable(path) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
});
|
|
175
|
+
export async function getVariable(path) {
|
|
176
|
+
const workspace = getWorkspace();
|
|
177
|
+
try {
|
|
178
|
+
const variable = await VariableService.getVariable({ workspace, path });
|
|
179
|
+
return variable.value;
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
throw Error(`Variable not found at ${path} or not visible to you`);
|
|
183
|
+
}
|
|
211
184
|
}
|
|
212
185
|
/**
|
|
213
186
|
* Set a variable by path, create if not exist
|
|
@@ -216,62 +189,54 @@ export function getVariable(path) {
|
|
|
216
189
|
* @param isSecretIfNotExist if the variable does not exist, create it as secret or not (default: false)
|
|
217
190
|
* @param descriptionIfNotExist if the variable does not exist, create it with this description (default: "")
|
|
218
191
|
*/
|
|
219
|
-
export function setVariable(path, value, isSecretIfNotExist, descriptionIfNotExist) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
192
|
+
export async function setVariable(path, value, isSecretIfNotExist, descriptionIfNotExist) {
|
|
193
|
+
const workspace = getWorkspace();
|
|
194
|
+
if (await VariableService.existsVariable({ workspace, path })) {
|
|
195
|
+
await VariableService.updateVariable({
|
|
196
|
+
workspace,
|
|
197
|
+
path,
|
|
198
|
+
requestBody: { value },
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
await VariableService.createVariable({
|
|
203
|
+
workspace,
|
|
204
|
+
requestBody: {
|
|
225
205
|
path,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
requestBody: {
|
|
233
|
-
path,
|
|
234
|
-
value,
|
|
235
|
-
is_secret: isSecretIfNotExist !== null && isSecretIfNotExist !== void 0 ? isSecretIfNotExist : false,
|
|
236
|
-
description: descriptionIfNotExist !== null && descriptionIfNotExist !== void 0 ? descriptionIfNotExist : "",
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
});
|
|
206
|
+
value,
|
|
207
|
+
is_secret: isSecretIfNotExist ?? false,
|
|
208
|
+
description: descriptionIfNotExist ?? "",
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}
|
|
241
212
|
}
|
|
242
|
-
function transformLeaves(d) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return d;
|
|
248
|
-
});
|
|
213
|
+
async function transformLeaves(d) {
|
|
214
|
+
for (const k in d) {
|
|
215
|
+
d[k] = await _transformLeaf(d[k]);
|
|
216
|
+
}
|
|
217
|
+
return d;
|
|
249
218
|
}
|
|
250
219
|
const VAR_RESOURCE_PREFIX = "$var:";
|
|
251
220
|
const RES_RESOURCE_PREFIX = "$res:";
|
|
252
|
-
function _transformLeaf(v) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
});
|
|
221
|
+
async function _transformLeaf(v) {
|
|
222
|
+
if (typeof v === "object") {
|
|
223
|
+
return transformLeaves(v);
|
|
224
|
+
}
|
|
225
|
+
else if (typeof v === "string" && v.startsWith(VAR_RESOURCE_PREFIX)) {
|
|
226
|
+
const varName = v.substring(VAR_RESOURCE_PREFIX.length);
|
|
227
|
+
return await getVariable(varName);
|
|
228
|
+
}
|
|
229
|
+
else if (typeof v === "string" && v.startsWith(RES_RESOURCE_PREFIX)) {
|
|
230
|
+
const resName = v.substring(RES_RESOURCE_PREFIX.length);
|
|
231
|
+
return await getResource(resName);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
return v;
|
|
235
|
+
}
|
|
269
236
|
}
|
|
270
|
-
export function databaseUrlFromResource(path) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
return `postgresql://${resource.user}:${resource.password}@${resource.host}:${resource.port}/${resource.dbname}?sslmode=${resource.sslmode}`;
|
|
274
|
-
});
|
|
237
|
+
export async function databaseUrlFromResource(path) {
|
|
238
|
+
const resource = await getResource(path);
|
|
239
|
+
return `postgresql://${resource.user}:${resource.password}@${resource.host}:${resource.port}/${resource.dbname}?sslmode=${resource.sslmode}`;
|
|
275
240
|
}
|
|
276
241
|
// /**
|
|
277
242
|
// * Get URLs needed for resuming a flow after this step
|
|
@@ -40,20 +40,18 @@ export class CancelablePromise {
|
|
|
40
40
|
__classPrivateFieldSet(this, _CancelablePromise_resolve, resolve, "f");
|
|
41
41
|
__classPrivateFieldSet(this, _CancelablePromise_reject, reject, "f");
|
|
42
42
|
const onResolve = (value) => {
|
|
43
|
-
var _a;
|
|
44
43
|
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
__classPrivateFieldSet(this, _CancelablePromise_isResolved, true, "f");
|
|
48
|
-
|
|
47
|
+
__classPrivateFieldGet(this, _CancelablePromise_resolve, "f")?.call(this, value);
|
|
49
48
|
};
|
|
50
49
|
const onReject = (reason) => {
|
|
51
|
-
var _a;
|
|
52
50
|
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
53
51
|
return;
|
|
54
52
|
}
|
|
55
53
|
__classPrivateFieldSet(this, _CancelablePromise_isRejected, true, "f");
|
|
56
|
-
|
|
54
|
+
__classPrivateFieldGet(this, _CancelablePromise_reject, "f")?.call(this, reason);
|
|
57
55
|
};
|
|
58
56
|
const onCancel = (cancelHandler) => {
|
|
59
57
|
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
@@ -86,7 +84,6 @@ export class CancelablePromise {
|
|
|
86
84
|
return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").finally(onFinally);
|
|
87
85
|
}
|
|
88
86
|
cancel() {
|
|
89
|
-
var _a;
|
|
90
87
|
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
91
88
|
return;
|
|
92
89
|
}
|
|
@@ -103,7 +100,7 @@ export class CancelablePromise {
|
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
102
|
__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length = 0;
|
|
106
|
-
|
|
103
|
+
__classPrivateFieldGet(this, _CancelablePromise_reject, "f")?.call(this, new CancelError('Request aborted'));
|
|
107
104
|
}
|
|
108
105
|
get isCancelled() {
|
|
109
106
|
return __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f");
|
package/dist/core/request.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
-
import type { ApiResult } from './ApiResult';
|
|
3
|
-
import { CancelablePromise } from './CancelablePromise';
|
|
4
|
-
import type { OnCancel } from './CancelablePromise';
|
|
5
|
-
import type { OpenAPIConfig } from './OpenAPI';
|
|
6
2
|
export declare const isDefined: <T>(value: T | null | undefined) => value is Exclude<T, null | undefined>;
|
|
7
3
|
export declare const isString: (value: any) => value is string;
|
|
8
4
|
export declare const isStringWithValue: (value: any) => value is string;
|
package/dist/core/request.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
/* generated using openapi-typescript-codegen -- do no edit */
|
|
11
2
|
/* istanbul ignore file */
|
|
12
3
|
/* tslint:disable */
|
|
13
4
|
/* eslint-disable */
|
|
14
|
-
import { ApiError } from './ApiError';
|
|
15
|
-
import { CancelablePromise } from './CancelablePromise';
|
|
5
|
+
import { ApiError } from './ApiError.js';
|
|
6
|
+
import { CancelablePromise } from './CancelablePromise.js';
|
|
16
7
|
export const isDefined = (value) => {
|
|
17
8
|
return value !== undefined && value !== null;
|
|
18
9
|
};
|
|
@@ -79,8 +70,7 @@ const getUrl = (config, options) => {
|
|
|
79
70
|
const path = options.url
|
|
80
71
|
.replace('{api-version}', config.VERSION)
|
|
81
72
|
.replace(/{(.*?)}/g, (substring, group) => {
|
|
82
|
-
|
|
83
|
-
if ((_a = options.path) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(group)) {
|
|
73
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
84
74
|
return encoder(String(options.path[group]));
|
|
85
75
|
}
|
|
86
76
|
return substring;
|
|
@@ -116,20 +106,27 @@ export const getFormData = (options) => {
|
|
|
116
106
|
}
|
|
117
107
|
return undefined;
|
|
118
108
|
};
|
|
119
|
-
export const resolve = (options, resolver) =>
|
|
109
|
+
export const resolve = async (options, resolver) => {
|
|
120
110
|
if (typeof resolver === 'function') {
|
|
121
111
|
return resolver(options);
|
|
122
112
|
}
|
|
123
113
|
return resolver;
|
|
124
|
-
}
|
|
125
|
-
export const getHeaders = (config, options) =>
|
|
126
|
-
const token =
|
|
127
|
-
const username =
|
|
128
|
-
const password =
|
|
129
|
-
const additionalHeaders =
|
|
130
|
-
const headers = Object.entries(
|
|
114
|
+
};
|
|
115
|
+
export const getHeaders = async (config, options) => {
|
|
116
|
+
const token = await resolve(options, config.TOKEN);
|
|
117
|
+
const username = await resolve(options, config.USERNAME);
|
|
118
|
+
const password = await resolve(options, config.PASSWORD);
|
|
119
|
+
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
120
|
+
const headers = Object.entries({
|
|
121
|
+
Accept: 'application/json',
|
|
122
|
+
...additionalHeaders,
|
|
123
|
+
...options.headers,
|
|
124
|
+
})
|
|
131
125
|
.filter(([_, value]) => isDefined(value))
|
|
132
|
-
.reduce((headers, [key, value]) => (
|
|
126
|
+
.reduce((headers, [key, value]) => ({
|
|
127
|
+
...headers,
|
|
128
|
+
[key]: String(value),
|
|
129
|
+
}), {});
|
|
133
130
|
if (isStringWithValue(token)) {
|
|
134
131
|
headers['Authorization'] = `Bearer ${token}`;
|
|
135
132
|
}
|
|
@@ -152,11 +149,10 @@ export const getHeaders = (config, options) => __awaiter(void 0, void 0, void 0,
|
|
|
152
149
|
}
|
|
153
150
|
}
|
|
154
151
|
return new Headers(headers);
|
|
155
|
-
}
|
|
152
|
+
};
|
|
156
153
|
export const getRequestBody = (options) => {
|
|
157
|
-
var _a;
|
|
158
154
|
if (options.body !== undefined) {
|
|
159
|
-
if (
|
|
155
|
+
if (options.mediaType?.includes('/json')) {
|
|
160
156
|
return JSON.stringify(options.body);
|
|
161
157
|
}
|
|
162
158
|
else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
@@ -168,11 +164,11 @@ export const getRequestBody = (options) => {
|
|
|
168
164
|
}
|
|
169
165
|
return undefined;
|
|
170
166
|
};
|
|
171
|
-
export const sendRequest = (config, options, url, body, formData, headers, onCancel) =>
|
|
167
|
+
export const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
172
168
|
const controller = new AbortController();
|
|
173
169
|
const request = {
|
|
174
170
|
headers,
|
|
175
|
-
body: body
|
|
171
|
+
body: body ?? formData,
|
|
176
172
|
method: options.method,
|
|
177
173
|
signal: controller.signal,
|
|
178
174
|
};
|
|
@@ -181,8 +177,8 @@ export const sendRequest = (config, options, url, body, formData, headers, onCan
|
|
|
181
177
|
request.referrerPolicy = "no-referrer";
|
|
182
178
|
}
|
|
183
179
|
onCancel(() => controller.abort());
|
|
184
|
-
return
|
|
185
|
-
}
|
|
180
|
+
return await fetch(url, request);
|
|
181
|
+
};
|
|
186
182
|
export const getResponseHeader = (response, responseHeader) => {
|
|
187
183
|
if (responseHeader) {
|
|
188
184
|
const content = response.headers.get(responseHeader);
|
|
@@ -192,7 +188,7 @@ export const getResponseHeader = (response, responseHeader) => {
|
|
|
192
188
|
}
|
|
193
189
|
return undefined;
|
|
194
190
|
};
|
|
195
|
-
export const getResponseBody = (response) =>
|
|
191
|
+
export const getResponseBody = async (response) => {
|
|
196
192
|
if (response.status !== 204) {
|
|
197
193
|
try {
|
|
198
194
|
const contentType = response.headers.get('Content-Type');
|
|
@@ -200,10 +196,10 @@ export const getResponseBody = (response) => __awaiter(void 0, void 0, void 0, f
|
|
|
200
196
|
const jsonTypes = ['application/json', 'application/problem+json'];
|
|
201
197
|
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
|
|
202
198
|
if (isJSON) {
|
|
203
|
-
return
|
|
199
|
+
return await response.json();
|
|
204
200
|
}
|
|
205
201
|
else {
|
|
206
|
-
return
|
|
202
|
+
return await response.text();
|
|
207
203
|
}
|
|
208
204
|
}
|
|
209
205
|
}
|
|
@@ -212,17 +208,25 @@ export const getResponseBody = (response) => __awaiter(void 0, void 0, void 0, f
|
|
|
212
208
|
}
|
|
213
209
|
}
|
|
214
210
|
return undefined;
|
|
215
|
-
}
|
|
211
|
+
};
|
|
216
212
|
export const catchErrorCodes = (options, result) => {
|
|
217
|
-
|
|
218
|
-
|
|
213
|
+
const errors = {
|
|
214
|
+
400: 'Bad Request',
|
|
215
|
+
401: 'Unauthorized',
|
|
216
|
+
403: 'Forbidden',
|
|
217
|
+
404: 'Not Found',
|
|
218
|
+
500: 'Internal Server Error',
|
|
219
|
+
502: 'Bad Gateway',
|
|
220
|
+
503: 'Service Unavailable',
|
|
221
|
+
...options.errors,
|
|
222
|
+
};
|
|
219
223
|
const error = errors[result.status];
|
|
220
224
|
if (error) {
|
|
221
225
|
throw new ApiError(options, result, error);
|
|
222
226
|
}
|
|
223
227
|
if (!result.ok) {
|
|
224
|
-
const errorStatus =
|
|
225
|
-
const errorStatusText =
|
|
228
|
+
const errorStatus = result.status ?? 'unknown';
|
|
229
|
+
const errorStatusText = result.statusText ?? 'unknown';
|
|
226
230
|
const errorBody = (() => {
|
|
227
231
|
try {
|
|
228
232
|
return JSON.stringify(result.body, null, 2);
|
|
@@ -242,22 +246,22 @@ export const catchErrorCodes = (options, result) => {
|
|
|
242
246
|
* @throws ApiError
|
|
243
247
|
*/
|
|
244
248
|
export const request = (config, options) => {
|
|
245
|
-
return new CancelablePromise((resolve, reject, onCancel) =>
|
|
249
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
246
250
|
try {
|
|
247
251
|
const url = getUrl(config, options);
|
|
248
252
|
const formData = getFormData(options);
|
|
249
253
|
const body = getRequestBody(options);
|
|
250
|
-
const headers =
|
|
254
|
+
const headers = await getHeaders(config, options);
|
|
251
255
|
if (!onCancel.isCancelled) {
|
|
252
|
-
const response =
|
|
253
|
-
const responseBody =
|
|
256
|
+
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
257
|
+
const responseBody = await getResponseBody(response);
|
|
254
258
|
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
255
259
|
const result = {
|
|
256
260
|
url,
|
|
257
261
|
ok: response.ok,
|
|
258
262
|
status: response.status,
|
|
259
263
|
statusText: response.statusText,
|
|
260
|
-
body: responseHeader
|
|
264
|
+
body: responseHeader ?? responseBody,
|
|
261
265
|
};
|
|
262
266
|
catchErrorCodes(options, result);
|
|
263
267
|
resolve(result.body);
|
|
@@ -266,5 +270,5 @@ export const request = (config, options) => {
|
|
|
266
270
|
catch (error) {
|
|
267
271
|
reject(error);
|
|
268
272
|
}
|
|
269
|
-
})
|
|
273
|
+
});
|
|
270
274
|
};
|