@stack-spot/portal-network 0.27.1 → 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 (47) hide show
  1. package/CHANGELOG.md +15 -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 +51 -0
  12. package/dist/client/content.d.ts.map +1 -1
  13. package/dist/client/content.js +64 -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/error/DefaultAPIError.d.ts.map +1 -1
  27. package/dist/error/DefaultAPIError.js +7 -4
  28. package/dist/error/DefaultAPIError.js.map +1 -1
  29. package/dist/error/dictionary/cnt.js +12 -12
  30. package/dist/error/dictionary/cnt.js.map +1 -1
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +1 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/network/ManualOperation.js +1 -1
  36. package/package.json +1 -1
  37. package/src/api/apiManagement.ts +498 -0
  38. package/src/api/workspaceManager.ts +402 -234
  39. package/src/apis.json +8 -8
  40. package/src/client/content.ts +43 -2
  41. package/src/client/types.ts +38 -0
  42. package/src/client/workspace-manager.ts +171 -0
  43. package/src/client/workspace.ts +40 -15
  44. package/src/error/DefaultAPIError.ts +9 -5
  45. package/src/error/dictionary/cnt.ts +12 -12
  46. package/src/index.ts +1 -1
  47. 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,16 +1,28 @@
1
1
  import { HttpError } from '@oazapfts/runtime'
2
- import { addLink, addWorkspace, changeVisibility, createStudio, defaults, deleteLink, deleteStudio, delWorkspace, getStackVersionListByIds, getStudioByIdOrSlug, getStudios1, getStudiosToCreateButton, getStudioTabs, listLinksByStackVersion, listReasons, listWorkspaces, stackModalViewSummary, updateStudio, updateStudioTabs, deleteV1StacksVersionsByStackVersionId, getStackWorkspaces, getStackWorkspaceDetailView, getUnusedStackVersions, getPluginModalView, getStackUsesPlugin, getGetPluginView, getPluginInfrastructureView, getApplicationsUsesPlugin, getStarterUsesPlugin, getPluginVersionsNotInUse, getPluginVersions, getDependentPluginsVersions, getStarterStackVersionsAndPluginsVersions, getInfrastructureEnvironmentsUsesPlugin, getApplicationDetailsView, stackVersionUsageSummary, deprecateStackVersionBy, getPluginVersionUsageSummary, deprecatePluginVersion, deletePluginVersion } 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() {
12
24
  super(apis.content.url, defaults)
13
- }
25
+ }
14
26
 
15
27
  protected buildStackSpotError(error: HttpError): StackspotAPIError {
16
28
  return new DefaultAPIError(error.data, error.status, cntDictionary, error.headers)
@@ -172,6 +184,35 @@ class ContentClient extends ReactQueryNetworkClient {
172
184
  * Delete a Plugin version of type draft or unpublish
173
185
  */
174
186
  deletePluginVersion = this.mutation(deletePluginVersion)
187
+ /**
188
+ * Update starter
189
+ */
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)
175
216
  }
176
217
 
177
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()
@@ -1,5 +1,6 @@
1
1
  import { Dictionary, Language } from '@stack-spot/portal-translate'
2
- import { ErrorResponse } from '../api/account'
2
+ import { every, isString } from 'lodash'
3
+ import { ErrorResponse, ValidationDetails } from '../api/account'
3
4
  import { StackspotAPIError } from './StackspotAPIError'
4
5
  import { baseDictionary } from './dictionary/base'
5
6
  import { cntFields } from './dictionary/cnt-fields'
@@ -21,17 +22,20 @@ function getTitle(status: number, raw: ErrorResponse, dictionary: Dictionary, la
21
22
  return (baseDictionary as Dictionary)[language][status] || baseDictionary[language].defaultTitle
22
23
  }
23
24
 
25
+ function getValues(detail: ValidationDetails) {
26
+ return detail.values && every(detail.values, isString) ? `\n${detail.values.join('\n')}` : ''
27
+ }
28
+
24
29
  function createMessage(status: number, raw: ErrorResponse, dictionary: Dictionary, language: Language) {
25
30
  const title = getTitle(status, raw, dictionary, language)
26
31
  if (!raw.validationDetails?.length) return title
27
32
  const api = raw.code?.split(/[-_]/)[0]
28
33
  const details = raw.validationDetails?.map((detail) => {
29
34
  const dict: Record<string, string> = (fieldDictionary[api?.toLowerCase() as keyof typeof fieldDictionary] ?? {})[language] ?? {}
30
- const name = dict[detail.code] || detail.field || (raw.code !== detail.code && dictionary[language][detail.code]) ||
31
- detail.details || detail.code
32
- return detail.values?.length ? `${name}${detail.values ? `\n${detail.values.join('\n')}` : ''}` : name
35
+ const name = dict[detail.code] || detail.field || (raw.code !== detail.code && dictionary[language][detail.code]) || detail.details || ''
36
+ return `${name}${getValues(detail)}`
33
37
  })?.filter(d => !!d)
34
- return details?.length === 1 ? details[0] : `${title}\n${details?.join('\n')}`
38
+ return details ? `${title}\n${details?.join('\n')}` : title
35
39
  }
36
40
 
37
41
  /**
@@ -23,13 +23,13 @@ export const cntDictionary = {
23
23
  CNT_STUDIO_CONTENT_USED_BY_WORKSPACE_ERROR: 'Changes to Studio visibility cannot be made because one or more Workspaces currently use this content.',
24
24
  CNT_STUDIO_VISIBILITY_CANT_BE_CHANGE_ERROR: 'Studio visibility cannot be changed.',
25
25
  CNT_CONTENT_INTERSECTION_ERROR: 'This content is being used.',
26
- CNT_STACK_VERSION_IS_IN_USE_ERROR: 'Workspaces are using this Stack version. The names of the Workspaces are {1-n}.',
27
- CNT_ACTION_VERSION_IS_IN_USE_ERROR: 'This Action version is in use and cannot be deleted. The Stacks using it are {1-n}.',
28
- CNT_PLUGIN_VERSION_IS_IN_USE_ERROR: 'This Plugin version is in use and cannot be deleted. The Stacks using it are {1-n}.',
26
+ CNT_STACK_VERSION_IS_IN_USE_ERROR: 'Workspaces are using this Stack version. The names of the Workspaces are: ',
27
+ CNT_ACTION_VERSION_IS_IN_USE_ERROR: 'This Action version is in use and cannot be deleted. The Stacks using it are: .',
28
+ CNT_PLUGIN_VERSION_IS_IN_USE_ERROR: 'This Plugin version is in use and cannot be deleted. The Stacks using it are: .',
29
29
  CNT_STUDIO_DELETE_ERROR: 'This Studio cannot be deleted. You can delete Studios without content or with restricted visibility.',
30
- CNT_STUDIO_PLUGIN_IS_IN_USE_IN_ANOTHER_STUDIO_ERROR: 'Visibility cannot be changed because Studio(s) {1-n} uses one or more Plugins.',
31
- CNT_STUDIO_ACTION_IS_IN_USE_IN_ANOTHER_STUDIO_ERROR: 'Visibility cannot be changed because one or more Actions are used by Studio(s) {1-n}.',
32
- CNT_PLUGIN_VERSION_IS_IN_CONNECTION_INTERFACE_ERROR: 'The Plugin is used in the infra setup of a Stack and cannot be deleted. Stacks using it are {1-n}.',
30
+ CNT_STUDIO_PLUGIN_IS_IN_USE_IN_ANOTHER_STUDIO_ERROR: 'Visibility cannot be changed because Studio(s) uses one or more Plugins: ',
31
+ CNT_STUDIO_ACTION_IS_IN_USE_IN_ANOTHER_STUDIO_ERROR: 'Visibility cannot be changed because one or more Actions are used by Studio(s): .',
32
+ CNT_PLUGIN_VERSION_IS_IN_CONNECTION_INTERFACE_ERROR: 'The Plugin is used in the infra setup of a Stack and cannot be deleted. Stacks using it are: .',
33
33
  CNT_STACK_VERSION_PUBLISH_CUSTOM_SEMVER_NOT_VALID_ERROR: 'A Stack version with the chosen semantic version already exists. Please select another version.',
34
34
  CNT_STACK_SEMANTIC_VERSION_INVALID_ERROR: 'Please select a different range.',
35
35
  CNT_PLUGIN_RANGE_VERSION_INVALID_ERROR: 'Invalid range. Please choose another one.',
@@ -61,13 +61,13 @@ export const cntDictionary = {
61
61
  CNT_STUDIO_CONTENT_USED_BY_WORKSPACE_ERROR: 'Não é possível alterar a visibilidade do Estúdio porque um ou mais Workspaces utilizam este conteúdo.',
62
62
  CNT_STUDIO_VISIBILITY_CANT_BE_CHANGE_ERROR: 'Não é possível alterar a visibilidade do Estúdio.',
63
63
  CNT_CONTENT_INTERSECTION_ERROR: 'Este conteúdo está sendo utilizado.',
64
- CNT_STACK_VERSION_IS_IN_USE_ERROR: 'Esta versão da Stack está em uso nos Workspaces: {1-n}.',
65
- CNT_ACTION_VERSION_IS_IN_USE_ERROR: 'Esta versão da Action está em uso e não pode ser deletada. As Stacks que a utilizam são: {1-n}.',
66
- CNT_PLUGIN_VERSION_IS_IN_USE_ERROR: 'Esta versão do Plugin está em uso e não pode ser deletada. As Stacks que a utilizam são: {1-n}.',
64
+ CNT_STACK_VERSION_IS_IN_USE_ERROR: 'Esta versão da Stack está em uso nos Workspaces: ',
65
+ CNT_ACTION_VERSION_IS_IN_USE_ERROR: 'Esta versão da Action está em uso e não pode ser deletada. As Stacks que a utilizam são: ',
66
+ CNT_PLUGIN_VERSION_IS_IN_USE_ERROR: 'Esta versão do Plugin está em uso e não pode ser deletada. As Stacks que a utilizam são: ',
67
67
  CNT_STUDIO_DELETE_ERROR: 'Você pode deletar apenas Estúdios sem conteúdo ou com visibilidade restrita.',
68
- CNT_STUDIO_PLUGIN_IS_IN_USE_IN_ANOTHER_STUDIO_ERROR: 'A visibilidade não pode ser alterada porque um ou mais Plugins estão sendo usados pelo(s) Estúdio(s) {1-n}.',
69
- CNT_STUDIO_ACTION_IS_IN_USE_IN_ANOTHER_STUDIO_ERROR: 'A visibilidade não pode ser alterada porque um ou mais Actions estão sendo usados pelo(s) Estúdio(s) {1-n}.',
70
- CNT_PLUGIN_VERSION_IS_IN_CONNECTION_INTERFACE_ERROR: 'O Plugin está em uso na configuração de infra de uma Stack e não pode ser deletado. As Stacks que o utilizam são {1-n}.',
68
+ CNT_STUDIO_PLUGIN_IS_IN_USE_IN_ANOTHER_STUDIO_ERROR: 'A visibilidade não pode ser alterada porque um ou mais Plugins estão sendo usados pelo(s) Estúdio(s): ',
69
+ CNT_STUDIO_ACTION_IS_IN_USE_IN_ANOTHER_STUDIO_ERROR: 'A visibilidade não pode ser alterada porque um ou mais Actions estão sendo usados pelo(s) Estúdio(s): ',
70
+ CNT_PLUGIN_VERSION_IS_IN_CONNECTION_INTERFACE_ERROR: 'O Plugin está em uso na configuração de infra de uma Stack e não pode ser deletado. As Stacks que o utilizam são: ',
71
71
  CNT_STACK_VERSION_PUBLISH_CUSTOM_SEMVER_NOT_VALID_ERROR: 'Uma versão da Stack com a versão semântica escolhida já existe. Por favor, escolha outra versão.',
72
72
  CNT_STACK_SEMANTIC_VERSION_INVALID_ERROR: 'Por favor, selecione um Range diferente.',
73
73
  CNT_PLUGIN_RANGE_VERSION_INVALID_ERROR: 'Range inválido. Por favor, escolha outro.',
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),