@stack-spot/portal-network 0.16.1 → 0.18.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.
@@ -0,0 +1,31 @@
1
+ import { HttpError } from '@oazapfts/runtime'
2
+ import { addLink, defaults, deleteLink, listLinksByStackVersion } from '../api/content'
3
+ import apis from '../apis.json'
4
+ import { DefaultAPIError } from '../error/DefaultAPIError'
5
+ import { cntDictionary } from '../error/dictionary/cnt'
6
+ import { StackspotAPIError } from '../error/StackspotAPIError'
7
+ import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
8
+
9
+ class ContentClient extends ReactQueryNetworkClient {
10
+ constructor() {
11
+ super(apis.content.url, defaults)
12
+ }
13
+
14
+ protected buildStackSpotError(error: HttpError): StackspotAPIError {
15
+ return new DefaultAPIError(error.data, error.status, cntDictionary, error.headers)
16
+ }
17
+ /**
18
+ * Gets links in a stack
19
+ */
20
+ linksInStack = this.query(listLinksByStackVersion)
21
+ /**
22
+ * Adds a link in a stack
23
+ */
24
+ addLinkInStack = this.mutation(addLink)
25
+ /**
26
+ * Adds a link in a stack
27
+ */
28
+ deleteLinkFromStack = this.mutation(deleteLink)
29
+ }
30
+
31
+ export const contentClient = new ContentClient()
@@ -1,7 +1,6 @@
1
1
  import { RequestOpts } from '@oazapfts/runtime'
2
- import { AccountScmInfoSaveRequest, AccountScmInfoUpdateRequest, AccountScmStatusResponse, IdResponse } from '../api/account'
2
+ import { AccountScmInfoSaveRequest, AccountScmInfoUpdateRequest, AccountScmStatusResponse } from '../api/account'
3
3
  import { AllocationCostRequest, AllocationCostResponse, ChargePeriod, getAllocationCostFilters, ManagedService, ServiceResource } from '../api/cloudServices'
4
- import { EnvironmentReadResponse, WorkspaceReadResponse } from '../api/workspace'
5
4
 
6
5
  interface BaseSMCStatus {
7
6
  /**
@@ -116,18 +115,3 @@ export type FixVariables<
116
115
 
117
116
  export type ReplaceResult<T extends (...args: any[]) => Promise<any>, Fix> = (...args: Parameters<T>) => Promise<Fix>
118
117
 
119
-
120
- export interface FixedWorkspaceReadResponse extends Omit<WorkspaceReadResponse, 'id' | 'name'> {
121
- id: string,
122
- name: string,
123
- }
124
-
125
- export interface FixedEnvironmentReadResponse extends Omit<EnvironmentReadResponse, 'id' | 'name'> {
126
- id: string,
127
- name: string,
128
- }
129
-
130
- export interface FixedIdResponse extends Omit<IdResponse, 'id'> {
131
- id: string,
132
- }
133
-
@@ -1,26 +1,49 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
2
  import {
3
+ checkConnectionSlugAvailability,
3
4
  save5 as createEmbeddedLink,
4
5
  defaults,
6
+ delete1,
7
+ delete2,
8
+ delete3,
9
+ delete5,
10
+ deleteAccountWorkflow,
5
11
  delete6 as deleteApplicationEmbeddedLinks,
6
12
  deleteConnectionInterfaceAttributesFromEnvironment, deleteConnectionInterfaceFromAllEnvironments,
7
13
  delete4 as deleteEmbeddedLink,
14
+ findAll,
8
15
  getEmbeddedLinks1 as getAllApplicationEmbeddedLinks,
9
16
  getApplication,
10
17
  getEmbeddedLink1 as getApplicationEmbeddedLinks,
18
+ getApplicationLink,
19
+ getAvailableConnectionInterfaceForAnApplication,
20
+ getAvailableConnectionInterfaceForAWorkspace,
11
21
  getConnectionInterface, getConnectionInterfaces,
12
22
  getDependencyTree,
13
23
  getDependencyTree1,
14
24
  getEmbeddedLink, getEmbeddedLinks, getEnvironment, getEnvironments,
25
+ getSharedInfraLink,
15
26
  getSharedInfrastructure,
27
+ getV1WorkspacesByWorkspaceIdVariablesAndName,
16
28
  getWorkspaceForId,
29
+ getWorkspaceLinks,
17
30
  getWorkspaces,
31
+ getWorkspacesFromUserPermission,
32
+ listAccountWorkflows,
33
+ listWorkflowByStackIdAndWorkflowType,
18
34
  save,
35
+ save1,
36
+ save3,
37
+ save4,
38
+ save7,
19
39
  save8 as saveApplicationEmbeddedLinks,
20
40
  save9 as saveEnvironment,
41
+ update,
21
42
  update1,
22
43
  update2,
44
+ update3,
23
45
  update6,
46
+ update7,
24
47
  upsertBatch2 as updateAllApplicationEmbeddedLinks,
25
48
  upsertBatch1 as updateAllEmbeddedLink,
26
49
  update8 as updateApplicationEmbeddedLinks,
@@ -28,13 +51,14 @@ import {
28
51
  updateConnectionInterfaceVisibility,
29
52
  update5 as updateEmbeddedLink,
30
53
  update9 as updateEnvironment,
54
+ updateLinksVisibility,
55
+ updateLinksVisibility1,
31
56
  } from '../api/workspace'
32
57
  import apis from '../apis.json'
33
58
  import { DefaultAPIError } from '../error/DefaultAPIError'
34
59
  import { workspaceDictionary } from '../error/dictionary/workspace'
35
60
  import { StackspotAPIError } from '../error/StackspotAPIError'
36
61
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
37
- import { FixedEnvironmentReadResponse, FixedIdResponse, FixedWorkspaceReadResponse, ReplaceResult } from './types'
38
62
 
39
63
  class WorkspaceClient extends ReactQueryNetworkClient {
40
64
  constructor() {
@@ -54,7 +78,14 @@ class WorkspaceClient extends ReactQueryNetworkClient {
54
78
  * Gets a connection interface from a workspace
55
79
  */
56
80
  connectionInterface = this.query(getConnectionInterface)
57
-
81
+ /**
82
+ * Get available connection interface for a workspace by connection interface slug
83
+ */
84
+ workspaceAvailableConnInterfaceBySlug = this.query(getAvailableConnectionInterfaceForAWorkspace)
85
+ /**
86
+ * Get available connection interface for an application by connection interface slug
87
+ */
88
+ applicationAvailableConnInterface = this.query(getAvailableConnectionInterfaceForAnApplication)
58
89
  /**
59
90
  * Updates the visibility of a connection interface
60
91
  */
@@ -74,16 +105,20 @@ class WorkspaceClient extends ReactQueryNetworkClient {
74
105
  * Updates the attributes of a connection interface
75
106
  */
76
107
  updateConnectionInterfaceAttributes = this.mutation(updateConnectionInterfaceAttributes)
108
+ /**
109
+ * Checks the availability of a connection interface slug.
110
+ */
111
+ checkConnectionInterfaceAvailability = this.query(checkConnectionSlugAvailability)
77
112
 
78
113
  /**
79
114
  * Gets all environments
80
115
  */
81
- environments = this.query(getEnvironments as unknown as ReplaceResult<typeof getEnvironments, FixedEnvironmentReadResponse[]>)
116
+ environments = this.query(getEnvironments)
82
117
 
83
118
  /**
84
119
  * Gets environment by Id
85
120
  */
86
- environment = this.query(getEnvironment as unknown as ReplaceResult<typeof getEnvironment, FixedEnvironmentReadResponse>)
121
+ environment = this.query(getEnvironment)
87
122
 
88
123
  /**
89
124
  * Creates an environment
@@ -158,23 +193,29 @@ class WorkspaceClient extends ReactQueryNetworkClient {
158
193
  /**
159
194
  * Gets all workspaces
160
195
  */
161
- workspaces = this.query(getWorkspaces as unknown as ReplaceResult<typeof getWorkspaces, FixedWorkspaceReadResponse[]>)
196
+ workspaces = this.query(getWorkspaces)
162
197
 
163
198
  /**
164
199
  * Gets a workspace
165
200
  */
166
- workspace = this.query(getWorkspaceForId as unknown as ReplaceResult<typeof getWorkspaceForId, FixedWorkspaceReadResponse>)
201
+ workspace = this.query(getWorkspaceForId)
202
+ /**
203
+ * Get workspaces within user permission
204
+ */
205
+ workspacesFromUserPermission = this.query(getWorkspacesFromUserPermission)
167
206
 
168
207
  /**
169
208
  * Creates a workspace
170
209
  */
171
- createWorkspace = this.mutation(save as unknown as ReplaceResult<typeof save, FixedIdResponse>)
210
+ createWorkspace = this.mutation(save)
172
211
 
173
212
  /**
174
213
  * Updates a workspace
175
214
  */
176
215
  updateWorkspace = this.mutation(update1)
177
216
 
217
+ //App and infra
218
+
178
219
  /**
179
220
  * Gets an application
180
221
  */
@@ -205,6 +246,99 @@ class WorkspaceClient extends ReactQueryNetworkClient {
205
246
  */
206
247
  updateInfra = this.mutation(update2)
207
248
 
249
+ // Workflow
250
+ /**
251
+ * Gets a workflow by stack id
252
+ */
253
+ workflowsByStackId = this.query(listWorkflowByStackIdAndWorkflowType)
254
+ /**
255
+ * Gets account workflows
256
+ */
257
+ accountWorkflows = this.query(listAccountWorkflows)
258
+ /**
259
+ * Gets workflows from a stack
260
+ */
261
+ stackWorkflows = this.query(listWorkflowByStackIdAndWorkflowType)
262
+ /**
263
+ * Removes account workflow
264
+ */
265
+ deleteAccountWorkflow = this.mutation(deleteAccountWorkflow)
266
+
267
+ // Variable
268
+ /**
269
+ * Gets all workspace variables
270
+ */
271
+ variables = this.query(findAll)
272
+ /**
273
+ * Creates a workspace variable
274
+ */
275
+ createVariable = this.mutation(save1)
276
+ /**
277
+ * Gets a variable by name
278
+ */
279
+ variable = this.query(getV1WorkspacesByWorkspaceIdVariablesAndName)
280
+ /**
281
+ * Updates a workspace variable
282
+ */
283
+ updateVariable = this.mutation(update)
284
+ /**
285
+ * Deletes a workspace variable
286
+ */
287
+ deleteVariable = this.mutation(delete1)
288
+
289
+ //Links
290
+ /**
291
+ * Gets shared infra links
292
+ */
293
+ linksInWorkspace = this.query(getWorkspaceLinks)
294
+ /**
295
+ * Adds a link to a workspace
296
+ */
297
+ addLinkInWorkspace = this.mutation(save4)
298
+ /**
299
+ * Deletes a link from a workspace
300
+ */
301
+ removeLinkFromWorkspace = this.mutation(delete3)
302
+ /**
303
+ * Gets application link
304
+ */
305
+ linkInApplication = this.query(getApplicationLink)
306
+ /**
307
+ * Adds a link to an application
308
+ */
309
+ addLinkInApplication = this.mutation(save7)
310
+ /**
311
+ * Deletes a link from an application
312
+ */
313
+ removeLinkFromApplication = this.mutation(delete5)
314
+ /**
315
+ * Updates a link from an application
316
+ */
317
+ updateLinkInApplication = this.mutation(update7)
318
+ /**
319
+ * Updates application links visibility
320
+ */
321
+ updateLinkVisibilityInApplication = this.mutation(updateLinksVisibility1)
322
+ /**
323
+ * Gets shared infra link
324
+ */
325
+ linkInInfra = this.query(getSharedInfraLink)
326
+ /**
327
+ * Adds a link to an infra
328
+ */
329
+ addLinkInInfra = this.mutation(save3)
330
+ /**
331
+ * Deletes a link from an infra
332
+ */
333
+ removeLinkFromInfra = this.mutation(delete2)
334
+ /**
335
+ * Updates a link from an infra
336
+ */
337
+ updateLinkInInfra = this.mutation(update3)
338
+ /**
339
+ * Updates infra links visibility
340
+ */
341
+ updateLinkVisibilityInInfra = this.mutation(updateLinksVisibility)
208
342
 
209
343
  }
210
344
 
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export { accountClient } from './client/account'
2
2
  export { cloudServicesClient } from './client/cloud-services'
3
3
  export { secretsClient } from './client/secrets'
4
4
  export { workspaceClient } from './client/workspace'
5
+ export { contentClient } from './client/content'
5
6
  export { runtimeManagerClient } from './client/runtime-manager'
6
7
  export { workspaceSearchClient } from './client/workspace-search'
7
8
  export { workflowClient } from './client/workflow'