@stack-spot/portal-network 0.27.2 → 0.28.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/api/apiManagement.d.ts +289 -0
  3. package/dist/api/apiManagement.d.ts.map +1 -0
  4. package/dist/api/apiManagement.js +143 -0
  5. package/dist/api/apiManagement.js.map +1 -0
  6. package/dist/api/workspaceManager.d.ts +320 -218
  7. package/dist/api/workspaceManager.d.ts.map +1 -1
  8. package/dist/api/workspaceManager.js +68 -20
  9. package/dist/api/workspaceManager.js.map +1 -1
  10. package/dist/apis.json +8 -8
  11. package/dist/client/content.d.ts +43 -0
  12. package/dist/client/content.d.ts.map +1 -1
  13. package/dist/client/content.js +55 -1
  14. package/dist/client/content.js.map +1 -1
  15. package/dist/client/notification.d.ts +1 -1
  16. package/dist/client/types.d.ts +29 -0
  17. package/dist/client/types.d.ts.map +1 -1
  18. package/dist/client/workspace-manager.d.ts +121 -0
  19. package/dist/client/workspace-manager.d.ts.map +1 -0
  20. package/dist/client/workspace-manager.js +204 -0
  21. package/dist/client/workspace-manager.js.map +1 -0
  22. package/dist/client/workspace.d.ts +45 -0
  23. package/dist/client/workspace.d.ts.map +1 -1
  24. package/dist/client/workspace.js +46 -1
  25. package/dist/client/workspace.js.map +1 -1
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +1 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/network/ManualOperation.js +1 -1
  31. package/package.json +1 -1
  32. package/src/api/apiManagement.ts +498 -0
  33. package/src/api/workspaceManager.ts +402 -234
  34. package/src/apis.json +8 -8
  35. package/src/client/content.ts +39 -2
  36. package/src/client/types.ts +38 -0
  37. package/src/client/workspace-manager.ts +171 -0
  38. package/src/client/workspace.ts +40 -15
  39. package/src/index.ts +1 -1
  40. package/src/network/ManualOperation.ts +1 -1
package/src/apis.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": {
12
12
  "dev": "https://workspace-workspace-api.dev.stackspot.com",
13
13
  "stg": "https://workspace-workspace-api.stg.stackspot.com",
14
- "prd": "https://workspace.v1.stackspot.com"
14
+ "prd": "https://workspace.stackspot.com"
15
15
  },
16
16
  "docs": "/v3/api-docs"
17
17
  },
@@ -19,7 +19,7 @@
19
19
  "url": {
20
20
  "dev": "https://account-account-api.dev.stackspot.com",
21
21
  "stg": "https://account-account-api.stg.stackspot.com",
22
- "prd": "https://account.v1.stackspot.com"
22
+ "prd": "https://account.stackspot.com"
23
23
  },
24
24
  "docs": "/v3/api-docs"
25
25
  },
@@ -27,7 +27,7 @@
27
27
  "url": {
28
28
  "dev": "https://content-content-api.dev.stackspot.com",
29
29
  "stg": "https://content-content-api.stg.stackspot.com",
30
- "prd": "https://content-api.v1.stackspot.com"
30
+ "prd": "https://content-api.stackspot.com"
31
31
  },
32
32
  "docs": "/v3/api-docs"
33
33
  },
@@ -43,7 +43,7 @@
43
43
  "url": {
44
44
  "dev": "https://catalog-tech-products-catalog-api.dev.stackspot.com",
45
45
  "stg": "https://catalog-tech-products-catalog-api.stg.stackspot.com",
46
- "prd": "https://catalog-api.v1.stackspot.com"
46
+ "prd": "https://catalog-api.stackspot.com"
47
47
  },
48
48
  "docs": "/v3/api-docs"
49
49
  },
@@ -51,7 +51,7 @@
51
51
  "url": {
52
52
  "dev": "https://runtime-manager.dev.stackspot.com",
53
53
  "stg": "https://runtime-manager.stg.stackspot.com",
54
- "prd": "https://runtime-manager.v1.stackspot.com"
54
+ "prd": "https://runtime-manager.stackspot.com"
55
55
  },
56
56
  "docs": "/v3/api-docs"
57
57
  },
@@ -91,7 +91,7 @@
91
91
  "url": {
92
92
  "dev": "https://workflow-workflow-api.dev.stackspot.com",
93
93
  "stg": "https://workflow-workflow-api.stg.stackspot.com",
94
- "prd": "https://workflow-api.v1.stackspot.com"
94
+ "prd": "https://workflow-api.stackspot.com"
95
95
  },
96
96
  "docs": "/openapi.json"
97
97
  },
@@ -99,7 +99,7 @@
99
99
  "url": {
100
100
  "dev": "https://workspace-workspace-manager.dev.stackspot.com",
101
101
  "stg": "https://workspace-workspace-manager.stg.stackspot.com",
102
- "prd": "https://workspace-manager.v1.stackspot.com"
102
+ "prd": "https://workspace-manager.stackspot.com"
103
103
  },
104
104
  "docs": "/v3/api-docs"
105
105
  },
@@ -130,7 +130,7 @@
130
130
  "url": {
131
131
  "dev": "https://workspace-workspace-secrets-api.dev.stackspot.com",
132
132
  "stg": "https://workspace-workspace-secrets-api.stg.stackspot.com",
133
- "prd": "https://secrets-api.v1.stackspot.com"
133
+ "prd": "https://secrets-api.stackspot.com"
134
134
  },
135
135
  "docs": "/v3/api-docs"
136
136
  },
@@ -1,11 +1,23 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import { addLink, addWorkspace, changeVisibility, createStudio, defaults, deleteLink, deletePluginVersion, deleteStudio, deleteV1StacksVersionsByStackVersionId, delWorkspace, deprecatePluginVersion, deprecateStackVersionBy, getApplicationDetailsView, getApplicationsUsesPlugin, getDependentPluginsVersions, getGetPluginView, getInfrastructureEnvironmentsUsesPlugin, getPluginInfrastructureView, getPluginModalView, getPluginVersions, getPluginVersionsNotInUse, getPluginVersionUsageSummary, getStackUsesPlugin, getStackVersionListByIds, getStackWorkspaceDetailView, getStackWorkspaces, getStarterStackVersionsAndPluginsVersions, getStarterUsesPlugin, getStudioByIdOrSlug, getStudios1, getStudiosToCreateButton, getStudioTabs, getUnusedStackVersions, listLinksByStackVersion, listReasons, listWorkspaces, patchStarterV2, stackModalViewSummary, stackVersionUsageSummary, updateStudio, updateStudioTabs } from '../api/content'
2
+ import {
3
+ addLink, addWorkspace, changeVisibility, createStudio, defaults, deleteLink, deleteStudio, delWorkspace,
4
+ getStackVersionListByIds, getStudioByIdOrSlug, getStudios1, getStudiosToCreateButton, getStudioTabs,
5
+ listConnectionInterfaceTypes, listLinksByStackVersion, listPluginVersionByIdsController, listReasons,
6
+ listWorkspaces, stackModalViewSummary, getListOfInputs, updateStudio, updateStudioTabs, deleteV1StacksVersionsByStackVersionId,
7
+ getStackWorkspaces, getStackWorkspaceDetailView, getUnusedStackVersions, getPluginModalView, getStackUsesPlugin,
8
+ getGetPluginView, getPluginInfrastructureView, getApplicationsUsesPlugin, getStarterUsesPlugin, getPluginVersionsNotInUse,
9
+ getPluginVersions, getDependentPluginsVersions, getStarterStackVersionsAndPluginsVersions, getInfrastructureEnvironmentsUsesPlugin,
10
+ getApplicationDetailsView, stackVersionUsageSummary, deprecateStackVersionBy, getPluginVersionUsageSummary, deprecatePluginVersion,
11
+ deletePluginVersion, patchStarterV2, listPlugins,
12
+ getActionsVersions, listStarters,
13
+ } from '../api/content'
3
14
  import apis from '../apis.json'
4
15
  import { DefaultAPIError } from '../error/DefaultAPIError'
5
16
  import { cntDictionary } from '../error/dictionary/cnt'
6
17
  import { StackspotAPIError } from '../error/StackspotAPIError'
7
18
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
8
19
  import { removeAuthorizationParam } from '../utils/remove-authorization-param'
20
+ import { OperationObject } from '../network/types'
9
21
 
10
22
  class ContentClient extends ReactQueryNetworkClient {
11
23
  constructor() {
@@ -83,7 +95,7 @@ class ContentClient extends ReactQueryNetworkClient {
83
95
  * Gets content deprecation reasons
84
96
  */
85
97
  deprecationReasons = this.query(listReasons)
86
-
98
+
87
99
  /**
88
100
  * Get usage summary of stack
89
101
  */
@@ -176,6 +188,31 @@ class ContentClient extends ReactQueryNetworkClient {
176
188
  * Update starter
177
189
  */
178
190
  updateStarter = this.mutation(patchStarterV2)
191
+ /**
192
+ * Gets connection interface types
193
+ */
194
+ connectionInterfaceTypes = this.query(listConnectionInterfaceTypes)
195
+ /**
196
+ * Gets a list of plugin versions from list of ids.
197
+ */
198
+ pluginVersionsByIds = this.query(listPluginVersionByIdsController)
199
+ /**
200
+ * Gets plugins from a stack version
201
+ */
202
+ listPluginsFromStack = this.query(listPlugins)
203
+ /**
204
+ * Gets the inputs of a specific Action. This fn is only used for permission purposes.
205
+ */
206
+ actionInputs = this.query(getListOfInputs) as
207
+ OperationObject<Parameters<typeof getListOfInputs>[0]>
208
+ /**
209
+ * Gets action versions by ids
210
+ */
211
+ actionsVersions = this.query(getActionsVersions)
212
+ /**
213
+ * Gets all starters from a stack version id
214
+ */
215
+ startersInStackVersion = this.query(listStarters)
179
216
  }
180
217
 
181
218
  export const contentClient = new ContentClient()
@@ -2,6 +2,7 @@ import { RequestOpts } from '@oazapfts/runtime'
2
2
  import { AccountScmInfoSaveRequest, AccountScmInfoUpdateRequest, AccountScmStatusResponse } from '../api/account'
3
3
  import { ConnectAccountRequestV2, ManagedAccountProvisionRequest } from '../api/cloudAccount'
4
4
  import { AllocationCostRequest, AllocationCostResponse, ChargePeriod, getAllocationCostFilters, ManagedService, ServiceResource } from '../api/cloudServices'
5
+ import { FullInputContextResponse, InputConditionResponse, InputValuesContextResponse, PluginForAppCreationV2Response, PluginInputValuesInConsolidatedContextResponse, ValueByEnvResponse } from '../api/workspaceManager'
5
6
 
6
7
  interface BaseSMCStatus {
7
8
  /**
@@ -116,6 +117,43 @@ export interface FixedManagedAccountProvisionRequest extends Omit<ManagedAccount
116
117
  workspaceId: string,
117
118
  }
118
119
 
120
+ export interface FixedPluginForAppCreationV2Response extends Omit<PluginForAppCreationV2Response, 'inputs'> {
121
+ inputs: FixedPluginInputValuesInConsolidatedContextResponse[],
122
+ }
123
+
124
+ export type InputType = 'BOOL' | 'INT' | 'MULTISELECT' | 'OBJECT' | 'LIST' | 'REQUIRED-CONNECTION' | 'PASSWORD' | 'SELECT' | 'TEXT'
125
+
126
+ export interface FixedInputConditionResponse extends Omit<InputConditionResponse, 'value'> {
127
+ value?: any,
128
+ }
129
+
130
+ export interface FixedValueByEnvResponse extends Omit<ValueByEnvResponse, 'value'> {
131
+ value: any,
132
+ }
133
+
134
+ export interface FixedInputValuesContextResponse extends Omit<InputValuesContextResponse,
135
+ 'inputs' | 'input' | 'type' | 'default' | 'condition' | 'valuesByEnv'> {
136
+ inputs: Omit<FixedInputValuesContextResponse, 'valuesByEnv'>[],
137
+ input?: Omit<FixedInputValuesContextResponse, 'valuesByEnv'>,
138
+ type: InputType,
139
+ default?: any,
140
+ condition?: FixedInputConditionResponse,
141
+ valuesByEnv: FixedValueByEnvResponse[],
142
+ }
143
+
144
+ export interface FixedFullInputContextResponse extends Omit<FullInputContextResponse, 'inputs'> {
145
+ inputs: FixedInputValuesContextResponse[],
146
+ }
147
+
148
+ export interface FixedPluginInputValuesInConsolidatedContextResponse extends
149
+ Omit<PluginInputValuesInConsolidatedContextResponse, 'inputs' | 'input' | 'type' | 'default' | 'condition'> {
150
+ inputs: FixedInputValuesContextResponse[],
151
+ input?: FixedInputValuesContextResponse,
152
+ type: InputType,
153
+ default?: any,
154
+ condition?: FixedInputConditionResponse,
155
+ }
156
+
119
157
  export type OazapftsFunction<Variables = any, Result = any> = (variables: Variables, opts?: RequestOpts) => Promise<Result>
120
158
 
121
159
  type Unpromisify<T> = T extends Promise<infer R> ? Unpromisify<R> : T
@@ -0,0 +1,171 @@
1
+ /* eslint-disable max-len */
2
+ import { HttpError } from '@oazapfts/runtime'
3
+ import {
4
+ defaults,
5
+ getAccountPluginInputs,
6
+ getApplicationAppliedPlugins,
7
+ getConsolidatedPluginInputs,
8
+ getSharedInfraAppliedPlugins,
9
+ listStacks1,
10
+ getStackActionInputsInWorkspaceContext,
11
+ getStackActionInputsInAccountContext,
12
+ upsertWorkspaceActionsInputContext,
13
+ upsertAccountActionsInputContext,
14
+ upsertPluginWorkspaceContext,
15
+ upsertPluginAccountContext,
16
+ getConsolidatedPluginInputsWithConnectionInterfaces,
17
+ listWorkflowByStackIdAndWorkflowType,
18
+ } from '../api/workspaceManager'
19
+ import apis from '../apis.json'
20
+ import { DefaultAPIError } from '../error/DefaultAPIError'
21
+ import { workspaceDictionary } from '../error/dictionary/workspace'
22
+ import { StackspotAPIError } from '../error/StackspotAPIError'
23
+ import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
24
+ import { contentClient } from './content'
25
+ import { FixedFullInputContextResponse, FixedPluginForAppCreationV2Response, ReplaceResult } from './types'
26
+ import { workspaceClient } from './workspace'
27
+
28
+ class WorkspaceManagerClient extends ReactQueryNetworkClient {
29
+ constructor() {
30
+ super(apis.workspaceManager.url, defaults)
31
+ }
32
+
33
+ protected buildStackSpotError(error: HttpError): StackspotAPIError {
34
+ return new DefaultAPIError(error.data, error.status, workspaceDictionary, error.headers)
35
+ }
36
+
37
+ /**
38
+ * Gets all stacks in a workspace
39
+ */
40
+ stacksInWorkspace = this.query({
41
+ name: 'stacksInWorkspace',
42
+ request: async (signal, variables: Parameters<typeof listStacks1>[0]) => listStacks1(variables, { signal }),
43
+ permission: async (variables: Parameters<typeof listStacks1>[0]) => {
44
+ const contentStacksPermission = await contentClient.allStackVersionByIds.isAllowed()
45
+ const workspaceStacksPermission = await workspaceClient.stacks.isAllowed(variables)
46
+ return workspaceStacksPermission && contentStacksPermission
47
+ },
48
+ })
49
+ /**
50
+ * Gets inputs from a plugin in a workspace stack
51
+ */
52
+ pluginInputsInWorkspace = this.query({
53
+ name: 'pluginInputsInWorkspace',
54
+ request: async (signal, variables: Parameters<typeof getConsolidatedPluginInputs>[0]) => {
55
+ const data = await getConsolidatedPluginInputs(variables, { signal })
56
+ return data as FixedFullInputContextResponse
57
+ },
58
+ permission: async ({ workspaceId, stackVersionId }: Parameters<typeof getConsolidatedPluginInputs>[0]) => {
59
+ const canViewContext = await workspaceClient.listConsolidatedWorkspaceContext.isAllowed({ $type: 'plugin', workspaceId, stackVersionId })
60
+ const canGetConnectionInterfaceTypes = await contentClient.connectionInterfaceTypes.isAllowed()
61
+ const canGetPluginVersions = await contentClient.pluginVersionsByIds.isAllowed({})
62
+ return canViewContext && canGetConnectionInterfaceTypes && canGetPluginVersions
63
+ },
64
+ })
65
+ /**
66
+ * Gets inputs from a plugin in account context
67
+ */
68
+ pluginInputsAccount = this.query({
69
+ name: 'pluginInputsAccount',
70
+ request: async (signal, variables: Parameters<typeof getAccountPluginInputs>[0]) => {
71
+ const data = await getAccountPluginInputs(variables, { signal })
72
+ return data as FixedFullInputContextResponse
73
+ },
74
+ permission: async ({ stackVersionId }: Parameters<typeof getAccountPluginInputs>[0]) => {
75
+ const canViewContext = await workspaceClient.listConsolidatedContext.isAllowed({ $type: 'plugin', stackVersionId })
76
+ const canGetConnectionInterfaceTypes = await contentClient.connectionInterfaceTypes.isAllowed()
77
+ const canGetPluginVersions = await contentClient.pluginVersionsByIds.isAllowed({})
78
+ return canViewContext && canGetConnectionInterfaceTypes && canGetPluginVersions
79
+ },
80
+ })
81
+ /**
82
+ * Update context inputs from an action in workspace
83
+ */
84
+ updateInputContextPluginWorkspace = this.mutation({
85
+ name: 'updateInputContextPluginWorkspace',
86
+ request: async (signal, variables: Parameters<typeof upsertPluginWorkspaceContext>[0]) =>
87
+ upsertPluginWorkspaceContext(variables, { signal }),
88
+ permission: async ({ stackVersionId, workspaceId, pluginVersionId }: Parameters<typeof upsertPluginWorkspaceContext>[0]) =>
89
+ workspaceClient.saveContextInWorkspace.isAllowed({ $type: 'plugin', workspaceId, stackVersionId, externalId: pluginVersionId }),
90
+ })
91
+ /**
92
+ * Update context inputs from an action in account
93
+ */
94
+ updateInputContextPluginAccount = this.mutation({
95
+ name: 'updateInputContextPluginAccount',
96
+ request: async (signal, variables: Parameters<typeof upsertPluginAccountContext>[0]) =>
97
+ upsertPluginAccountContext(variables, { signal }),
98
+ permission: async ({ stackVersionId, pluginVersionId }: Parameters<typeof upsertPluginAccountContext>[0]) =>
99
+ workspaceClient.saveContextInAccount.isAllowed({ $type: 'plugin', stackVersionId, externalId: pluginVersionId }),
100
+ })
101
+
102
+ /**
103
+ * Gets applied plugins in shared infra
104
+ */
105
+ appliedPluginsSharedInfra = this.query(getSharedInfraAppliedPlugins)
106
+ /**
107
+ * Gets applied plugins in application
108
+ */
109
+ appliedPluginsApplication = this.query(getApplicationAppliedPlugins)
110
+ /**
111
+ * Gets plugin inputs and connection interface from a plugin in a stack version in workspace
112
+ */
113
+ pluginInputsWithConnectionInterfaces = this.query(getConsolidatedPluginInputsWithConnectionInterfaces as unknown as ReplaceResult<typeof getConsolidatedPluginInputsWithConnectionInterfaces, FixedPluginForAppCreationV2Response>)
114
+ /**
115
+ * Gets workflows from a given stack and workflow type
116
+ */
117
+ workflowsByStackIdAndWorkflowType = this.query(listWorkflowByStackIdAndWorkflowType)
118
+
119
+ /**
120
+ * Gets inputs from an action in a workspace
121
+ */
122
+ actionInputsInWorkspace = this.query({
123
+ name: 'actionInputsInWorkspace',
124
+ request: async (signal, variables: Parameters<typeof getStackActionInputsInWorkspaceContext>[0]) => {
125
+ const data = await getStackActionInputsInWorkspaceContext(variables, { signal })
126
+ return data as FixedFullInputContextResponse
127
+ },
128
+ permission: async ({ workspaceId, stackVersionId, actionsVersionId }: Parameters<typeof getStackActionInputsInWorkspaceContext>[0]) => {
129
+ const canViewContext = await workspaceClient.listConsolidatedWorkspaceContext.isAllowed({ $type: 'action', workspaceId, stackVersionId })
130
+ const canGetActionInput = await contentClient.actionInputs.isAllowed({ actionVersionId: actionsVersionId })
131
+ return canViewContext && canGetActionInput
132
+ },
133
+ })
134
+ /**
135
+ * Gets inputs from an action in account context
136
+ */
137
+ actionInputsAccount = this.query({
138
+ name: 'actionInputsFromStack',
139
+ request: async (signal, variables: Parameters<typeof getStackActionInputsInAccountContext>[0]) => {
140
+ const data = await getStackActionInputsInAccountContext(variables, { signal })
141
+ return data as FixedFullInputContextResponse
142
+ },
143
+ permission: async ({ stackVersionId, actionsVersionId }: Parameters<typeof getStackActionInputsInAccountContext>[0]) => {
144
+ const canViewContext = await workspaceClient.listConsolidatedContext.isAllowed({ $type: 'action', stackVersionId })
145
+ const canGetActionInput = await contentClient.actionInputs.isAllowed({ actionVersionId: actionsVersionId })
146
+ return canViewContext && canGetActionInput
147
+ },
148
+ })
149
+ /**
150
+ * Update context inputs from an action in workspace
151
+ */
152
+ updateInputContextActionWorkspace = this.mutation({
153
+ name: 'updateInputContextActionWorkspace',
154
+ request: async (signal, variables: Parameters<typeof upsertWorkspaceActionsInputContext>[0]) =>
155
+ upsertWorkspaceActionsInputContext(variables, { signal }),
156
+ permission: async ({ stackVersionId, workspaceId, actionVersionId }: Parameters<typeof upsertWorkspaceActionsInputContext>[0]) =>
157
+ workspaceClient.saveContextInWorkspace.isAllowed({ $type: 'action', workspaceId, stackVersionId, externalId: actionVersionId }),
158
+ })
159
+ /**
160
+ * Update context inputs from an action in account
161
+ */
162
+ updateInputContextActionAccount = this.mutation({
163
+ name: 'updateInputContextActionAccount',
164
+ request: async (signal, variables: Parameters<typeof upsertAccountActionsInputContext>[0]) =>
165
+ upsertAccountActionsInputContext(variables, { signal }),
166
+ permission: async ({ stackVersionId, actionVersionId }: Parameters<typeof upsertAccountActionsInputContext>[0]) =>
167
+ workspaceClient.saveContextInAccount.isAllowed({ $type: 'action', stackVersionId, externalId: actionVersionId }),
168
+ })
169
+ }
170
+
171
+ export const workspaceManagerClient = new WorkspaceManagerClient()
@@ -26,12 +26,15 @@ import {
26
26
  getEmbeddedLink, getEmbeddedLinks, getEnvironment, getEnvironments,
27
27
  getSharedInfraLink,
28
28
  getSharedInfrastructure,
29
+ getStacks,
29
30
  getV1WorkspacesByWorkspaceIdVariablesAndName,
30
31
  getWorkspaceForId,
31
32
  getWorkspaceLinks,
32
33
  getWorkspaces,
33
34
  getWorkspacesFromUserPermission,
35
+ listAccountContext,
34
36
  listAccountWorkflows,
37
+ listConsolidatedContext,
35
38
  listWorkflowByStackIdAndWorkflowType,
36
39
  save,
37
40
  save1,
@@ -55,12 +58,15 @@ import {
55
58
  update9 as updateEnvironment,
56
59
  updateLinksVisibility,
57
60
  updateLinksVisibility1,
61
+ addTypedContextInWorkspace,
62
+ addTypedContextInAccount,
58
63
  } from '../api/workspace'
59
64
  import apis from '../apis.json'
60
65
  import { DefaultAPIError } from '../error/DefaultAPIError'
61
66
  import { workspaceDictionary } from '../error/dictionary/workspace'
62
67
  import { StackspotAPIError } from '../error/StackspotAPIError'
63
68
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
69
+ import { OperationObject } from '../network/types'
64
70
 
65
71
  class WorkspaceClient extends ReactQueryNetworkClient {
66
72
  constructor() {
@@ -70,7 +76,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
70
76
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
71
77
  return new DefaultAPIError(error.data, error.status, workspaceDictionary, error.headers)
72
78
  }
73
-
79
+
74
80
  /**
75
81
  * Gets all connection interfaces from a workspace
76
82
  */
@@ -102,7 +108,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
102
108
  * Removes connection interface attributes by environment
103
109
  */
104
110
  deleteConnectionInterfaceAttributesFromEnvironment = this.mutation(deleteConnectionInterfaceAttributesFromEnvironment)
105
-
111
+
106
112
  /**
107
113
  * Updates the attributes of a connection interface
108
114
  */
@@ -141,27 +147,27 @@ class WorkspaceClient extends ReactQueryNetworkClient {
141
147
  * Gets all embedded links from a workspace
142
148
  */
143
149
  allEmbeddedLinksInWorkspace = this.query(getEmbeddedLinks)
144
-
150
+
145
151
  /**
146
152
  * Creates an embedded link in a workspace
147
153
  */
148
154
  createEmbeddedLinkInWorkspace = this.mutation(createEmbeddedLink)
149
-
155
+
150
156
  /**
151
157
  * Deletes an embedded link from a workspace
152
158
  */
153
159
  deleteEmbeddedLinkFromWorkspace = this.mutation(deleteEmbeddedLink)
154
-
160
+
155
161
  /**
156
162
  * Updates an embedded link from a workspace
157
163
  */
158
164
  updateEmbeddedLinkInWorkspace = this.mutation(updateEmbeddedLink)
159
-
165
+
160
166
  /**
161
167
  * Updates all embedded links from a workspace
162
168
  */
163
169
  updateAllEmbeddedLinksInWorkspace = this.mutation(updateAllEmbeddedLink)
164
-
170
+
165
171
  /**
166
172
  * Gets an embedded link from an application
167
173
  */
@@ -171,7 +177,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
171
177
  * Gets all embedded links from an application
172
178
  */
173
179
  allEmbeddedLinksInApplication = this.query(getAllApplicationEmbeddedLinks)
174
-
180
+
175
181
  /**
176
182
  * Creates an embedded link in an application
177
183
  */
@@ -186,12 +192,12 @@ class WorkspaceClient extends ReactQueryNetworkClient {
186
192
  * Updates an embedded link in an application
187
193
  */
188
194
  updateEmbeddedLinkInApplication = this.mutation(updateApplicationEmbeddedLinks)
189
-
195
+
190
196
  /**
191
197
  * Updates all embedded links in an application
192
198
  */
193
199
  updateAllEmbeddedLinksInApplication = this.mutation(updateAllApplicationEmbeddedLinks)
194
-
200
+
195
201
  /**
196
202
  * Gets all workspaces
197
203
  */
@@ -214,8 +220,8 @@ class WorkspaceClient extends ReactQueryNetworkClient {
214
220
  /**
215
221
  * Updates a workspace
216
222
  */
217
- updateWorkspace = this.mutation(update1)
218
-
223
+ updateWorkspace = this.mutation(update1)
224
+
219
225
  //App and infra
220
226
  /**
221
227
  * Gets all applications in a Workspace
@@ -243,7 +249,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
243
249
  * Gets the dependencies of a shared infra
244
250
  */
245
251
  sharedInfraDependencies = this.query(getDependencyTree)
246
-
252
+
247
253
  /**
248
254
  * Updates an application
249
255
  */
@@ -293,7 +299,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
293
299
  * Deletes a workspace variable
294
300
  */
295
301
  deleteVariable = this.mutation(delete1)
296
-
302
+
297
303
  //Links
298
304
  /**
299
305
  * Gets shared infra links
@@ -347,7 +353,26 @@ class WorkspaceClient extends ReactQueryNetworkClient {
347
353
  * Updates infra links visibility
348
354
  */
349
355
  updateLinkVisibilityInInfra = this.mutation(updateLinksVisibility)
350
-
356
+ /**
357
+ * Gets stacks in a workspace. This fn is only used for permission purposes.
358
+ */
359
+ stacks = this.query(getStacks) as OperationObject<Parameters<typeof getStacks>[0]>
360
+ /**
361
+ * List workspace context inputs for a plugin or action in a stack. This fn is only used for permission purposes.
362
+ */
363
+ listConsolidatedWorkspaceContext = this.query(listConsolidatedContext) as OperationObject<Parameters<typeof listConsolidatedContext>[0]>
364
+ /**
365
+ * List account context inputs for a plugin or action in a stack. This fn is only used for permission purposes.
366
+ */
367
+ listConsolidatedContext = this.query(listAccountContext) as OperationObject<Parameters<typeof listAccountContext>[0]>
368
+ /**
369
+ * Save workspace context inputs for a plugin or action in a stack. This fn is only used for permission purposes.
370
+ */
371
+ saveContextInWorkspace = this.query(addTypedContextInWorkspace) as OperationObject<Parameters<typeof addTypedContextInWorkspace>[0]>
372
+ /**
373
+ * Save workspace context inputs for a plugin or action in a stack. This fn is only used for permission purposes.
374
+ */
375
+ saveContextInAccount = this.query(addTypedContextInAccount) as OperationObject<Parameters<typeof addTypedContextInAccount>[0]>
351
376
  }
352
377
 
353
378
  export const workspaceClient = new WorkspaceClient()
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export { secretsClient } from './client/secrets'
9
9
  export * from './client/types'
10
10
  export { workflowClient } from './client/workflow'
11
11
  export { workspaceClient } from './client/workspace'
12
+ export { workspaceManagerClient } from './client/workspace-manager'
12
13
  export { workspaceSearchClient } from './client/workspace-search'
13
14
  export { DefaultAPIError } from './error/DefaultAPIError'
14
15
  export { StackspotAPIError } from './error/StackspotAPIError'
@@ -16,4 +17,3 @@ export { NetworkClient } from './network/NetworkClient'
16
17
  export { queryClient } from './network/react-query-client'
17
18
  export { OperationResult, OperationVariables, UseQueryObjectOptions } from './network/types'
18
19
  export { useExtendedList } from './utils/use-extended-list'
19
-
@@ -39,7 +39,7 @@ export abstract class ManualOperation<Variables extends Record<string, any> | vo
39
39
  its arity is zero. We can use this information to determine what the type of `args` actually is at runtime. If variables are accepted,
40
40
  than the 1st argument is the variables and the 2nd is the query options, otherwise, it has a single argument, which is the query
41
41
  options. */
42
- const [variables, options] = this.config.permission.length === 2 ? args : [undefined, args[0]]
42
+ const [variables, options] = this.config.permission.length === 1 ? args : [undefined, args[0]]
43
43
  const result = useQuery({
44
44
  ...options,
45
45
  queryKey: this.getPermissionKey(variables as Variables),