@stack-spot/portal-network 0.13.0 → 0.14.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/CHANGELOG.md +15 -0
- package/dist/api/eventBus.d.ts +64 -0
- package/dist/api/eventBus.d.ts.map +1 -0
- package/dist/api/eventBus.js +41 -0
- package/dist/api/eventBus.js.map +1 -0
- package/dist/api/workspace.js +19 -72
- package/dist/api/workspace.js.map +1 -1
- package/dist/apis.json +9 -1
- package/dist/client/event-bus.d.ts +22 -0
- package/dist/client/event-bus.d.ts.map +1 -0
- package/dist/client/event-bus.js +98 -0
- package/dist/client/event-bus.js.map +1 -0
- package/dist/client/workspace.d.ts +71 -0
- package/dist/client/workspace.d.ts.map +1 -1
- package/dist/client/workspace.js +91 -1
- package/dist/client/workspace.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/api/eventBus.ts +171 -0
- package/src/api/workspace.ts +82 -200
- package/src/apis.json +9 -1
- package/src/client/event-bus.ts +82 -0
- package/src/client/workspace.ts +61 -0
- package/src/index.ts +1 -0
package/src/api/workspace.ts
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* DO NOT MODIFY - This file has been generated using oazapfts.
|
|
5
5
|
* See https://www.npmjs.com/package/oazapfts
|
|
6
6
|
*/
|
|
7
|
-
import * as Oazapfts from "@oazapfts/runtime"
|
|
8
|
-
import * as QS from "@oazapfts/runtime/query"
|
|
7
|
+
import * as Oazapfts from "@oazapfts/runtime";
|
|
8
|
+
import * as QS from "@oazapfts/runtime/query";
|
|
9
9
|
export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
|
|
10
10
|
headers: {},
|
|
11
|
-
baseUrl: "https://workspace
|
|
11
|
+
baseUrl: "https://workspace.v1.stackspot.com",
|
|
12
12
|
};
|
|
13
13
|
const oazapfts = Oazapfts.runtime(defaults);
|
|
14
14
|
export const servers = {
|
|
15
|
-
generatedServerUrl: "https://workspace
|
|
15
|
+
generatedServerUrl: "https://workspace.v1.stackspot.com"
|
|
16
16
|
};
|
|
17
17
|
export type ContextAttributeDto = {
|
|
18
18
|
key: string;
|
|
@@ -301,38 +301,6 @@ export type StackWorkflowCreateRequest = {
|
|
|
301
301
|
actionsBefore: WorkflowActionContextRequest[];
|
|
302
302
|
actionsAfter: WorkflowActionContextRequest[];
|
|
303
303
|
};
|
|
304
|
-
export type EnvironmentSimpleResponse = {
|
|
305
|
-
/** Environment id. */
|
|
306
|
-
id?: string;
|
|
307
|
-
/** Environment name. */
|
|
308
|
-
name?: string;
|
|
309
|
-
};
|
|
310
|
-
export type TargetByPluginUsageResponse = {
|
|
311
|
-
/** Plugin Version ID. */
|
|
312
|
-
pluginVersionId?: string;
|
|
313
|
-
environment?: EnvironmentSimpleResponse;
|
|
314
|
-
};
|
|
315
|
-
export type WorkspaceResponse = {
|
|
316
|
-
/** Workspace id. */
|
|
317
|
-
id?: string;
|
|
318
|
-
/** Workspace name */
|
|
319
|
-
name?: string;
|
|
320
|
-
/** Workspace description */
|
|
321
|
-
description?: string;
|
|
322
|
-
/** Workspace image */
|
|
323
|
-
imageUrl?: string;
|
|
324
|
-
};
|
|
325
|
-
export type PluginUsageByTargetResponse = {
|
|
326
|
-
/** Application id. */
|
|
327
|
-
id?: string;
|
|
328
|
-
/** Application name. */
|
|
329
|
-
name?: string;
|
|
330
|
-
/** Application description. */
|
|
331
|
-
description?: string;
|
|
332
|
-
/** Amount of linked versions. */
|
|
333
|
-
totalLinkedVersions?: number;
|
|
334
|
-
workspace?: WorkspaceResponse;
|
|
335
|
-
};
|
|
336
304
|
export type WorkspaceReadResponse = {
|
|
337
305
|
/** Workspace id. */
|
|
338
306
|
id?: string;
|
|
@@ -346,6 +314,8 @@ export type WorkspaceReadResponse = {
|
|
|
346
314
|
manageRuntime?: boolean;
|
|
347
315
|
/** Workspace accountId. */
|
|
348
316
|
accountId?: string;
|
|
317
|
+
/** Workspace teams. - deprecated field */
|
|
318
|
+
teams?: string[];
|
|
349
319
|
/** Workspace creator. */
|
|
350
320
|
createdBy?: string;
|
|
351
321
|
/** Workspace creation date. */
|
|
@@ -397,15 +367,6 @@ export type StackWithWorkspaceContextResponse = {
|
|
|
397
367
|
/** Account id. */
|
|
398
368
|
accountId?: string;
|
|
399
369
|
};
|
|
400
|
-
export type WorkspaceByStackUsageResponse = {
|
|
401
|
-
/** Stack Version ID. */
|
|
402
|
-
stackVersionId?: string;
|
|
403
|
-
/** Amount of linked applications. */
|
|
404
|
-
totalLinkedApps?: number;
|
|
405
|
-
/** Amount of linked shared infrastructure. */
|
|
406
|
-
totalLinkedInfra?: number;
|
|
407
|
-
environment?: EnvironmentSimpleResponse;
|
|
408
|
-
};
|
|
409
370
|
export type SharedInfraDetailsResponse = {
|
|
410
371
|
/** Shared infrastructure id. */
|
|
411
372
|
id?: string;
|
|
@@ -640,9 +601,9 @@ export type CreateApplicationRequest = {
|
|
|
640
601
|
/** Application repository base branch. */
|
|
641
602
|
repoBaseBranch: string;
|
|
642
603
|
/** Stack used to generate this application. */
|
|
643
|
-
stackVersionId
|
|
604
|
+
stackVersionId: string;
|
|
644
605
|
/** Starter used to generate this application. */
|
|
645
|
-
starterId
|
|
606
|
+
starterId: string;
|
|
646
607
|
};
|
|
647
608
|
export type RecreateApplicationRequest = {
|
|
648
609
|
/** Application name. */
|
|
@@ -789,23 +750,6 @@ export type ApplicationDeploySnapshotRequest = {
|
|
|
789
750
|
/** Input attributes for applied app plugin. */
|
|
790
751
|
plugins?: PluginElementSnapshot[];
|
|
791
752
|
};
|
|
792
|
-
export type StackUsageByWorkspaceResponse = {
|
|
793
|
-
/** Workspace id. */
|
|
794
|
-
id?: string;
|
|
795
|
-
/** Workspace name */
|
|
796
|
-
name?: string;
|
|
797
|
-
/** Workspace description */
|
|
798
|
-
description?: string;
|
|
799
|
-
/** Workspace image */
|
|
800
|
-
imageUrl?: string;
|
|
801
|
-
/** Amount of linked versions. */
|
|
802
|
-
totalLinkedVersions?: number;
|
|
803
|
-
};
|
|
804
|
-
export type PluginUsageAmountResponse = {
|
|
805
|
-
pluginVersionId: string;
|
|
806
|
-
totalUsedInInfras: number;
|
|
807
|
-
totalUsedInApps: number;
|
|
808
|
-
};
|
|
809
753
|
export type EnvironmentReadResponse = {
|
|
810
754
|
/** Environment id. */
|
|
811
755
|
id?: string;
|
|
@@ -953,6 +897,8 @@ export type AppliedPluginV2Response = {
|
|
|
953
897
|
links?: Link[];
|
|
954
898
|
};
|
|
955
899
|
export type ConnectionInterfaceSummaryV2Response = {
|
|
900
|
+
/** Connection interface api id. */
|
|
901
|
+
apiId?: string;
|
|
956
902
|
/** Connection interface id type generate by client. */
|
|
957
903
|
typeId?: string;
|
|
958
904
|
/** Connection interface id generated by client. */
|
|
@@ -1041,6 +987,30 @@ export type ActivityResponse = {
|
|
|
1041
987
|
[key: string]: object;
|
|
1042
988
|
};
|
|
1043
989
|
};
|
|
990
|
+
export type PaginatedActivityResponse = {
|
|
991
|
+
items: ActivityResponse[];
|
|
992
|
+
currentPage: number;
|
|
993
|
+
totalItems: number;
|
|
994
|
+
totalPages: number;
|
|
995
|
+
pageSize: number;
|
|
996
|
+
hasNextPage: boolean;
|
|
997
|
+
};
|
|
998
|
+
export type AppDependencyConnInterfaceResponse = {
|
|
999
|
+
name: string;
|
|
1000
|
+
"type": string;
|
|
1001
|
+
};
|
|
1002
|
+
export type Dependencies = {
|
|
1003
|
+
environmentName: string;
|
|
1004
|
+
hasSelfHostedInfra: boolean;
|
|
1005
|
+
hasApplication: boolean;
|
|
1006
|
+
connectionInterfaces: AppDependencyConnInterfaceResponse[];
|
|
1007
|
+
};
|
|
1008
|
+
export type AppAndInfraDependencyResponse = {
|
|
1009
|
+
canDelete: boolean;
|
|
1010
|
+
hasSelfHostedInfra: boolean;
|
|
1011
|
+
hasApplication: boolean;
|
|
1012
|
+
dependencies: Dependencies[];
|
|
1013
|
+
};
|
|
1044
1014
|
export type ConnectionInterfaceDetailsResponse = {
|
|
1045
1015
|
/** Connection interface id. */
|
|
1046
1016
|
id?: string;
|
|
@@ -1122,14 +1092,6 @@ export type ApplicationDeployInfoResponse = {
|
|
|
1122
1092
|
appDeploy?: AppDeployResponse;
|
|
1123
1093
|
infraDeploy?: InfraDeployResponse;
|
|
1124
1094
|
};
|
|
1125
|
-
export type AppDependencyConnInterfaceResponse = {
|
|
1126
|
-
name: string;
|
|
1127
|
-
"type": string;
|
|
1128
|
-
};
|
|
1129
|
-
export type ApplicationDependencyResponse = {
|
|
1130
|
-
environment: string;
|
|
1131
|
-
connectionInterfaces: AppDependencyConnInterfaceResponse[];
|
|
1132
|
-
};
|
|
1133
1095
|
export type EnvironmentsRequest = {
|
|
1134
1096
|
environmentId: string;
|
|
1135
1097
|
environmentName?: string;
|
|
@@ -1171,6 +1133,12 @@ export type CheckConnectionSlugAvailabilityResponse = {
|
|
|
1171
1133
|
/** Whether connection slug is available or not. */
|
|
1172
1134
|
available?: boolean;
|
|
1173
1135
|
};
|
|
1136
|
+
export type WorkspaceResponse = {
|
|
1137
|
+
/** Workspace id. */
|
|
1138
|
+
id?: string;
|
|
1139
|
+
/** Workspace name. */
|
|
1140
|
+
name?: string;
|
|
1141
|
+
};
|
|
1174
1142
|
export type ApplicationRepoUrlReadResponse = {
|
|
1175
1143
|
/** Application id. */
|
|
1176
1144
|
id?: string;
|
|
@@ -2088,53 +2056,6 @@ export function saveStackWorkflowContext({ stackId, workflowId, stackWorkflowCre
|
|
|
2088
2056
|
body: stackWorkflowCreateRequest
|
|
2089
2057
|
})));
|
|
2090
2058
|
}
|
|
2091
|
-
/**
|
|
2092
|
-
* List specific shared infra or application usage by plugin list.
|
|
2093
|
-
*/
|
|
2094
|
-
export function listPluginUsageByTargetId({ accountId, targetType, targetId, body }: {
|
|
2095
|
-
accountId: string;
|
|
2096
|
-
targetType: "applications" | "shared_infra";
|
|
2097
|
-
targetId: string;
|
|
2098
|
-
body: string[];
|
|
2099
|
-
}, opts?: Oazapfts.RequestOpts) {
|
|
2100
|
-
return oazapfts.ok(oazapfts.fetchJson<{
|
|
2101
|
-
status: 200;
|
|
2102
|
-
data: TargetByPluginUsageResponse[];
|
|
2103
|
-
} | {
|
|
2104
|
-
status: 403;
|
|
2105
|
-
data: ErrorResponse;
|
|
2106
|
-
}>(`/v1/${encodeURIComponent(targetType)}/${encodeURIComponent(targetId)}/plugins/usage`, oazapfts.json({
|
|
2107
|
-
...opts,
|
|
2108
|
-
method: "POST",
|
|
2109
|
-
body,
|
|
2110
|
-
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
2111
|
-
accountId
|
|
2112
|
-
})
|
|
2113
|
-
})));
|
|
2114
|
-
}
|
|
2115
|
-
/**
|
|
2116
|
-
* List all shared infras or applications usage by plugin list.
|
|
2117
|
-
*/
|
|
2118
|
-
export function listAllPluginUsage({ accountId, targetType, body }: {
|
|
2119
|
-
accountId: string;
|
|
2120
|
-
targetType: "applications" | "shared_infra";
|
|
2121
|
-
body: string[];
|
|
2122
|
-
}, opts?: Oazapfts.RequestOpts) {
|
|
2123
|
-
return oazapfts.ok(oazapfts.fetchJson<{
|
|
2124
|
-
status: 200;
|
|
2125
|
-
data: PluginUsageByTargetResponse[];
|
|
2126
|
-
} | {
|
|
2127
|
-
status: 403;
|
|
2128
|
-
data: ErrorResponse;
|
|
2129
|
-
}>(`/v1/${encodeURIComponent(targetType)}/plugins/usage`, oazapfts.json({
|
|
2130
|
-
...opts,
|
|
2131
|
-
method: "POST",
|
|
2132
|
-
body,
|
|
2133
|
-
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
2134
|
-
accountId
|
|
2135
|
-
})
|
|
2136
|
-
})));
|
|
2137
|
-
}
|
|
2138
2059
|
/**
|
|
2139
2060
|
* Get all workspaces
|
|
2140
2061
|
*/
|
|
@@ -2322,29 +2243,6 @@ export function getStacksWithContext({ workspaceId, body }: {
|
|
|
2322
2243
|
body
|
|
2323
2244
|
})));
|
|
2324
2245
|
}
|
|
2325
|
-
/**
|
|
2326
|
-
* List specific workspace usage by stack version list.
|
|
2327
|
-
*/
|
|
2328
|
-
export function listStackUsageByWorkspaceId({ accountId, workspaceId, body }: {
|
|
2329
|
-
accountId: string;
|
|
2330
|
-
workspaceId: string;
|
|
2331
|
-
body: string[];
|
|
2332
|
-
}, opts?: Oazapfts.RequestOpts) {
|
|
2333
|
-
return oazapfts.ok(oazapfts.fetchJson<{
|
|
2334
|
-
status: 200;
|
|
2335
|
-
data: WorkspaceByStackUsageResponse[];
|
|
2336
|
-
} | {
|
|
2337
|
-
status: 403;
|
|
2338
|
-
data: ErrorResponse;
|
|
2339
|
-
}>(`/v1/workspaces/${encodeURIComponent(workspaceId)}/stacks/usage`, oazapfts.json({
|
|
2340
|
-
...opts,
|
|
2341
|
-
method: "POST",
|
|
2342
|
-
body,
|
|
2343
|
-
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
2344
|
-
accountId
|
|
2345
|
-
})
|
|
2346
|
-
})));
|
|
2347
|
-
}
|
|
2348
2246
|
/**
|
|
2349
2247
|
* Get all shared infrastructure of a workspace.
|
|
2350
2248
|
*/
|
|
@@ -3291,56 +3189,6 @@ export function processDeploySnapshot1({ workspaceId, applicationId, application
|
|
|
3291
3189
|
body: applicationDeploySnapshotRequest
|
|
3292
3190
|
})));
|
|
3293
3191
|
}
|
|
3294
|
-
/**
|
|
3295
|
-
* List all workspaces usage by stack version list.
|
|
3296
|
-
*/
|
|
3297
|
-
export function listAllStackUsage({ accountId, body }: {
|
|
3298
|
-
accountId: string;
|
|
3299
|
-
body: string[];
|
|
3300
|
-
}, opts?: Oazapfts.RequestOpts) {
|
|
3301
|
-
return oazapfts.ok(oazapfts.fetchJson<{
|
|
3302
|
-
status: 200;
|
|
3303
|
-
data: StackUsageByWorkspaceResponse[];
|
|
3304
|
-
} | {
|
|
3305
|
-
status: 403;
|
|
3306
|
-
data: ErrorResponse;
|
|
3307
|
-
}>("/v1/workspaces/stacks/usage", oazapfts.json({
|
|
3308
|
-
...opts,
|
|
3309
|
-
method: "POST",
|
|
3310
|
-
body,
|
|
3311
|
-
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
3312
|
-
accountId
|
|
3313
|
-
})
|
|
3314
|
-
})));
|
|
3315
|
-
}
|
|
3316
|
-
/**
|
|
3317
|
-
* Retrieve the amount of apps and shared infras that use the given plugin version id list
|
|
3318
|
-
*/
|
|
3319
|
-
export function findPluginUsageAmount({ accountId, body }: {
|
|
3320
|
-
accountId: string;
|
|
3321
|
-
body: string[];
|
|
3322
|
-
}, opts?: Oazapfts.RequestOpts) {
|
|
3323
|
-
return oazapfts.ok(oazapfts.fetchJson<{
|
|
3324
|
-
status: 200;
|
|
3325
|
-
data: PluginUsageAmountResponse[];
|
|
3326
|
-
} | {
|
|
3327
|
-
status: 400;
|
|
3328
|
-
data: ErrorResponse;
|
|
3329
|
-
} | {
|
|
3330
|
-
status: 403;
|
|
3331
|
-
data: ErrorResponse;
|
|
3332
|
-
} | {
|
|
3333
|
-
status: 500;
|
|
3334
|
-
data: ErrorResponse;
|
|
3335
|
-
}>("/v1/plugin-usage", oazapfts.json({
|
|
3336
|
-
...opts,
|
|
3337
|
-
method: "POST",
|
|
3338
|
-
body,
|
|
3339
|
-
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
3340
|
-
accountId
|
|
3341
|
-
})
|
|
3342
|
-
})));
|
|
3343
|
-
}
|
|
3344
3192
|
/**
|
|
3345
3193
|
* Get environments
|
|
3346
3194
|
*/
|
|
@@ -4428,15 +4276,17 @@ export function getAppliedPlugins2({ workspaceId, sharedInfraId, environmentId,
|
|
|
4428
4276
|
/**
|
|
4429
4277
|
* List shared infrastructure's activities.
|
|
4430
4278
|
*/
|
|
4431
|
-
export function listActivities({ workspaceId, sharedInfraId, environmentId, $type }: {
|
|
4279
|
+
export function listActivities({ workspaceId, sharedInfraId, environmentId, $type, page, size }: {
|
|
4432
4280
|
workspaceId: string;
|
|
4433
4281
|
sharedInfraId: string;
|
|
4434
4282
|
environmentId: string;
|
|
4435
4283
|
$type?: "DEPLOY" | "ACTION" | "WORKFLOW" | "DRIFT" | "DESTROY" | "ROLLBACK" | "IAC" | "DEPLOY_SELF_HOSTED" | "DESTROY_SELF_HOSTED" | "ROLLBACK_SELF_HOSTED" | "IAC_SELF_HOSTED" | "CUSTOMER_WORKFLOW";
|
|
4284
|
+
page: number;
|
|
4285
|
+
size: number;
|
|
4436
4286
|
}, opts?: Oazapfts.RequestOpts) {
|
|
4437
4287
|
return oazapfts.ok(oazapfts.fetchJson<{
|
|
4438
4288
|
status: 200;
|
|
4439
|
-
data:
|
|
4289
|
+
data: PaginatedActivityResponse;
|
|
4440
4290
|
} | {
|
|
4441
4291
|
status: 400;
|
|
4442
4292
|
data: ErrorResponse;
|
|
@@ -4450,11 +4300,39 @@ export function listActivities({ workspaceId, sharedInfraId, environmentId, $typ
|
|
|
4450
4300
|
status: 500;
|
|
4451
4301
|
data: ErrorResponse;
|
|
4452
4302
|
}>(`/v1/workspaces/${encodeURIComponent(workspaceId)}/shared-infra/${encodeURIComponent(sharedInfraId)}/environments/${encodeURIComponent(environmentId)}/activities${QS.query(QS.explode({
|
|
4453
|
-
"type": $type
|
|
4303
|
+
"type": $type,
|
|
4304
|
+
page,
|
|
4305
|
+
size
|
|
4454
4306
|
}))}`, {
|
|
4455
4307
|
...opts
|
|
4456
4308
|
}));
|
|
4457
4309
|
}
|
|
4310
|
+
/**
|
|
4311
|
+
* Get all in use connection interface dependencies from the shared infra.
|
|
4312
|
+
*/
|
|
4313
|
+
export function getDependencyTree({ workspaceId, sharedInfraId }: {
|
|
4314
|
+
workspaceId: string;
|
|
4315
|
+
sharedInfraId: string;
|
|
4316
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
4317
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
4318
|
+
status: 200;
|
|
4319
|
+
data: AppAndInfraDependencyResponse;
|
|
4320
|
+
} | {
|
|
4321
|
+
status: 400;
|
|
4322
|
+
data: ErrorResponse;
|
|
4323
|
+
} | {
|
|
4324
|
+
status: 403;
|
|
4325
|
+
data: ErrorResponse;
|
|
4326
|
+
} | {
|
|
4327
|
+
status: 404;
|
|
4328
|
+
data: ErrorResponse;
|
|
4329
|
+
} | {
|
|
4330
|
+
status: 500;
|
|
4331
|
+
data: ErrorResponse;
|
|
4332
|
+
}>(`/v1/workspaces/${encodeURIComponent(workspaceId)}/shared-infra/${encodeURIComponent(sharedInfraId)}/dependencies`, {
|
|
4333
|
+
...opts
|
|
4334
|
+
}));
|
|
4335
|
+
}
|
|
4458
4336
|
/**
|
|
4459
4337
|
* Get a connection interface by connection interface id.
|
|
4460
4338
|
*/
|
|
@@ -4651,15 +4529,17 @@ export function getAppDeployInfo({ workspaceId, applicationId, environmentId, ac
|
|
|
4651
4529
|
/**
|
|
4652
4530
|
* List application's activities.
|
|
4653
4531
|
*/
|
|
4654
|
-
export function listActivities1({ workspaceId, applicationId, environmentId, $type }: {
|
|
4532
|
+
export function listActivities1({ workspaceId, applicationId, environmentId, $type, page, size }: {
|
|
4655
4533
|
workspaceId: string;
|
|
4656
4534
|
applicationId: string;
|
|
4657
4535
|
environmentId: string;
|
|
4658
4536
|
$type?: "DEPLOY" | "ACTION" | "WORKFLOW" | "DRIFT" | "DESTROY" | "ROLLBACK" | "IAC" | "DEPLOY_SELF_HOSTED" | "DESTROY_SELF_HOSTED" | "ROLLBACK_SELF_HOSTED" | "IAC_SELF_HOSTED" | "CUSTOMER_WORKFLOW";
|
|
4537
|
+
page: number;
|
|
4538
|
+
size: number;
|
|
4659
4539
|
}, opts?: Oazapfts.RequestOpts) {
|
|
4660
4540
|
return oazapfts.ok(oazapfts.fetchJson<{
|
|
4661
4541
|
status: 200;
|
|
4662
|
-
data:
|
|
4542
|
+
data: PaginatedActivityResponse;
|
|
4663
4543
|
} | {
|
|
4664
4544
|
status: 400;
|
|
4665
4545
|
data: ErrorResponse;
|
|
@@ -4673,7 +4553,9 @@ export function listActivities1({ workspaceId, applicationId, environmentId, $ty
|
|
|
4673
4553
|
status: 500;
|
|
4674
4554
|
data: ErrorResponse;
|
|
4675
4555
|
}>(`/v1/workspaces/${encodeURIComponent(workspaceId)}/applications/${encodeURIComponent(applicationId)}/environments/${encodeURIComponent(environmentId)}/activities${QS.query(QS.explode({
|
|
4676
|
-
"type": $type
|
|
4556
|
+
"type": $type,
|
|
4557
|
+
page,
|
|
4558
|
+
size
|
|
4677
4559
|
}))}`, {
|
|
4678
4560
|
...opts
|
|
4679
4561
|
}));
|
|
@@ -4681,13 +4563,13 @@ export function listActivities1({ workspaceId, applicationId, environmentId, $ty
|
|
|
4681
4563
|
/**
|
|
4682
4564
|
* Get all in use connection interface dependencies from the application.
|
|
4683
4565
|
*/
|
|
4684
|
-
export function
|
|
4566
|
+
export function getDependencyTree1({ workspaceId, applicationId }: {
|
|
4685
4567
|
workspaceId: string;
|
|
4686
4568
|
applicationId: string;
|
|
4687
4569
|
}, opts?: Oazapfts.RequestOpts) {
|
|
4688
4570
|
return oazapfts.ok(oazapfts.fetchJson<{
|
|
4689
4571
|
status: 200;
|
|
4690
|
-
data:
|
|
4572
|
+
data: AppAndInfraDependencyResponse;
|
|
4691
4573
|
} | {
|
|
4692
4574
|
status: 400;
|
|
4693
4575
|
data: ErrorResponse;
|
package/src/apis.json
CHANGED
|
@@ -31,6 +31,14 @@
|
|
|
31
31
|
},
|
|
32
32
|
"docs": "/v3/api-docs"
|
|
33
33
|
},
|
|
34
|
+
"eventBus": {
|
|
35
|
+
"url": {
|
|
36
|
+
"dev": "https://idp-event-bus-api.dev.stackspot.com",
|
|
37
|
+
"stg": "https://idp-event-bus-api.stg.stackspot.com",
|
|
38
|
+
"prd": "https://event-bus-api.stackspot.com"
|
|
39
|
+
},
|
|
40
|
+
"docs": "/v3/api-docs"
|
|
41
|
+
},
|
|
34
42
|
"serviceCatalog": {
|
|
35
43
|
"url": {
|
|
36
44
|
"dev": "https://catalog-tech-products-catalog-api.dev.stackspot.com",
|
|
@@ -43,7 +51,7 @@
|
|
|
43
51
|
"url": {
|
|
44
52
|
"dev": "https://runtime-manager.dev.stackspot.com",
|
|
45
53
|
"stg": "https://runtime-manager.stg.stackspot.com",
|
|
46
|
-
"prd": "https://runtime-
|
|
54
|
+
"prd": "https://runtime-manager.v1.stackspot.com"
|
|
47
55
|
},
|
|
48
56
|
"docs": "/v3/api-docs"
|
|
49
57
|
},
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
+
import { CompletablePromise } from '@stack-spot/opa'
|
|
3
|
+
import { cloneDeep } from 'lodash'
|
|
4
|
+
import { defaults, EventProcessingResponse, Event as EventType, sendEvents } from '../api/eventBus'
|
|
5
|
+
import apis from '../apis.json'
|
|
6
|
+
import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
7
|
+
import { baseDictionary } from '../error/dictionary/base'
|
|
8
|
+
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
9
|
+
import { NetworkClient } from '../network/NetworkClient'
|
|
10
|
+
|
|
11
|
+
export const EVENTS_STORAGE_IDENTIFIER = 'eventsError'
|
|
12
|
+
const DEFER_MS = 5000
|
|
13
|
+
class EventBusClient extends NetworkClient {
|
|
14
|
+
private queue: EventType[] = []
|
|
15
|
+
private deferred = new CompletablePromise<EventProcessingResponse>()
|
|
16
|
+
private timeout: number | undefined
|
|
17
|
+
private lock = false
|
|
18
|
+
|
|
19
|
+
constructor() {
|
|
20
|
+
super(apis.eventBus.url)
|
|
21
|
+
defaults.baseUrl = ''
|
|
22
|
+
defaults.fetch = (...args) => this.fetch(...args)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
protected buildStackSpotError(error: HttpError): StackspotAPIError {
|
|
26
|
+
return new DefaultAPIError(error.data, error.status, baseDictionary, error.headers)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private async consume() {
|
|
30
|
+
if (this.queue.length === 0) return
|
|
31
|
+
if (this.lock) return this.timeout = window.setTimeout(() => this.consume(), DEFER_MS)
|
|
32
|
+
|
|
33
|
+
this.lock = true
|
|
34
|
+
const deferred = this.deferred
|
|
35
|
+
this.deferred = new CompletablePromise()
|
|
36
|
+
const sendingQueue = cloneDeep(this.queue)
|
|
37
|
+
this.queue = []
|
|
38
|
+
|
|
39
|
+
const storageEvents = JSON.parse(localStorage.getItem(EVENTS_STORAGE_IDENTIFIER) || '[]')
|
|
40
|
+
|
|
41
|
+
const bodyData = {
|
|
42
|
+
events: sendingQueue.concat(storageEvents),
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const allResults: EventProcessingResponse = await sendEvents({ sendEventsRequest: bodyData })
|
|
47
|
+
|
|
48
|
+
if (allResults.errorCount === 0) {
|
|
49
|
+
localStorage.removeItem(EVENTS_STORAGE_IDENTIFIER)
|
|
50
|
+
}
|
|
51
|
+
deferred.resolve(allResults)
|
|
52
|
+
|
|
53
|
+
} catch (error: any) {
|
|
54
|
+
if (error instanceof HttpError) {
|
|
55
|
+
deferred.reject(new Error(`Error while sending events. Network error ${error.status}.\n}`))
|
|
56
|
+
}
|
|
57
|
+
throw error
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private async add(event: EventType) {
|
|
62
|
+
if (this.timeout) window.clearTimeout(this.timeout)
|
|
63
|
+
const index = this.queue.length
|
|
64
|
+
this.queue.push(event)
|
|
65
|
+
this.timeout = window.setTimeout(() => this.consume(), DEFER_MS)
|
|
66
|
+
const response = await this.deferred.promise
|
|
67
|
+
const result = response.results[index]
|
|
68
|
+
if ('errorCode' in result) {
|
|
69
|
+
throw result
|
|
70
|
+
}
|
|
71
|
+
return result
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Sends an event
|
|
76
|
+
*/
|
|
77
|
+
sendEvent = async (event: EventType) => {
|
|
78
|
+
await this.add(event)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const eventBusClient = new EventBusClient()
|
package/src/client/workspace.ts
CHANGED
|
@@ -6,11 +6,21 @@ import {
|
|
|
6
6
|
deleteConnectionInterfaceAttributesFromEnvironment, deleteConnectionInterfaceFromAllEnvironments,
|
|
7
7
|
delete4 as deleteEmbeddedLink,
|
|
8
8
|
getEmbeddedLinks1 as getAllApplicationEmbeddedLinks,
|
|
9
|
+
getApplication,
|
|
9
10
|
getEmbeddedLink1 as getApplicationEmbeddedLinks,
|
|
10
11
|
getConnectionInterface, getConnectionInterfaces,
|
|
12
|
+
getDependencyTree,
|
|
13
|
+
getDependencyTree1,
|
|
11
14
|
getEmbeddedLink, getEmbeddedLinks, getEnvironment, getEnvironments,
|
|
15
|
+
getSharedInfrastructure,
|
|
16
|
+
getWorkspaceForId,
|
|
17
|
+
getWorkspaces,
|
|
18
|
+
save,
|
|
12
19
|
save8 as saveApplicationEmbeddedLinks,
|
|
13
20
|
save9 as saveEnvironment,
|
|
21
|
+
update1,
|
|
22
|
+
update2,
|
|
23
|
+
update6,
|
|
14
24
|
upsertBatch2 as updateAllApplicationEmbeddedLinks,
|
|
15
25
|
upsertBatch1 as updateAllEmbeddedLink,
|
|
16
26
|
update8 as updateApplicationEmbeddedLinks,
|
|
@@ -144,6 +154,57 @@ class WorkspaceClient extends ReactQueryNetworkClient {
|
|
|
144
154
|
*/
|
|
145
155
|
updateAllEmbeddedLinksInApplication = this.mutation(updateAllApplicationEmbeddedLinks)
|
|
146
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Gets all workspaces
|
|
159
|
+
*/
|
|
160
|
+
workspaces = this.query(getWorkspaces)
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Gets a workspace
|
|
164
|
+
*/
|
|
165
|
+
workspace = this.query(getWorkspaceForId)
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Creates a workspace
|
|
169
|
+
*/
|
|
170
|
+
createWorkspace = this.mutation(save)
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Updates a workspace
|
|
174
|
+
*/
|
|
175
|
+
updateWorkspace = this.mutation(update1)
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Gets an application
|
|
179
|
+
*/
|
|
180
|
+
application = this.query(getApplication)
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Gets the dependencies of an application
|
|
184
|
+
*/
|
|
185
|
+
applicationDependencies = this.query(getDependencyTree1)
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Gets a shared infra
|
|
189
|
+
*/
|
|
190
|
+
sharedInfra = this.query(getSharedInfrastructure)
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Gets the dependencies of a shared infra
|
|
194
|
+
*/
|
|
195
|
+
sharedInfraDependencies = this.query(getDependencyTree)
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Updates an application
|
|
199
|
+
*/
|
|
200
|
+
updateApplication = this.mutation(update6)
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Updates a shared infra
|
|
204
|
+
*/
|
|
205
|
+
updateInfra = this.mutation(update2)
|
|
206
|
+
|
|
207
|
+
|
|
147
208
|
}
|
|
148
209
|
|
|
149
210
|
export const workspaceClient = new WorkspaceClient()
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { workspaceClient } from './client/workspace'
|
|
|
4
4
|
export { runtimeManagerClient } from './client/runtime-manager'
|
|
5
5
|
export { workspaceSearchClient } from './client/workspace-search'
|
|
6
6
|
export { workflowClient } from './client/workflow'
|
|
7
|
+
export { eventBusClient } from './client/event-bus'
|
|
7
8
|
export * from './client/types'
|
|
8
9
|
export { DefaultAPIError } from './error/DefaultAPIError'
|
|
9
10
|
export { StackspotAPIError } from './error/StackspotAPIError'
|