@stack-spot/portal-network 0.58.0 → 0.58.2

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.
@@ -510,20 +510,15 @@ class AccountClient extends ReactQueryNetworkClient {
510
510
  */
511
511
  validatePermissionAccess = this.query({
512
512
  name: 'account.getAccess',
513
- request: async (signal,
514
- { resourceType, resource, action, attribute }: {
515
- resourceType: string,
516
- resource: string,
517
- action: string,
518
- attribute?: string,
519
- }) => {
513
+ request: async (signal, variables: Parameters<typeof getAccess>[0]) => {
520
514
  try {
521
- await getAccess({ action, resource, resourceType, attribute }, { signal })
515
+ await getAccess(variables, { signal })
522
516
  return true
523
517
  } catch {
524
518
  return false
525
519
  }
526
520
  },
521
+ permission: this.createPermissionFunctionFor(getAccess),
527
522
  })
528
523
  }
529
524
 
@@ -7,11 +7,6 @@ import {
7
7
  accountVariableControllerfindByName,
8
8
  accountVariableControllerupdate,
9
9
  accountVariableControllerusage,
10
- applicationControllerdeleteApplication,
11
- applicationControllergetApplication,
12
- applicationControllergetApplications,
13
- applicationControllergetDependencyTree,
14
- applicationControllerupdate,
15
10
  applicationEmbeddedLinkControllerdelete,
16
11
  applicationEmbeddedLinkControllergetEmbeddedLink,
17
12
  applicationEmbeddedLinkControllergetEmbeddedLinks,
@@ -46,14 +41,14 @@ import {
46
41
  sharedInfraLinkControllersave,
47
42
  sharedInfraLinkControllerupdate,
48
43
  sharedInfraLinkControllerupdateLinksVisibility,
49
- sharedInfrastructureControllerdeleteSharedInfra,
50
- sharedInfrastructureControllergetAllSharedInfrastructure,
51
- sharedInfrastructureControllergetDependencyTree,
52
- sharedInfrastructureControllergetSharedInfrastructure,
53
- sharedInfrastructureControllerupdate,
54
44
  workflowAccountControllerdeleteAccountWorkflow,
55
45
  workflowAccountControllerlistAccountWorkflows,
56
46
  workflowWorkspaceControllerlistWorkflowByStackIdAndWorkflowType,
47
+ workspaceApplicationControllerdeleteApplication,
48
+ workspaceApplicationControllergetApplication,
49
+ workspaceApplicationControllergetApplications,
50
+ workspaceApplicationControllergetDependencyTree,
51
+ workspaceApplicationControllerupdate,
57
52
  workspaceControllerdelete,
58
53
  workspaceControllergetWorkspaceForId,
59
54
  workspaceControllergetWorkspaces,
@@ -69,6 +64,11 @@ import {
69
64
  workspaceLinkControllerdelete,
70
65
  workspaceLinkControllergetWorkspaceLinks,
71
66
  workspaceLinkControllersave,
67
+ workspaceSharedInfrastructureControllerdeleteSharedInfra,
68
+ workspaceSharedInfrastructureControllergetAllSharedInfrastructure,
69
+ workspaceSharedInfrastructureControllergetDependencyTree,
70
+ workspaceSharedInfrastructureControllergetSharedInfrastructure,
71
+ workspaceSharedInfrastructureControllerupdate,
72
72
  workspaceStackControlleraddStack,
73
73
  workspaceStackControllerdeleteStack,
74
74
  workspaceStackControllergetStackById,
@@ -125,7 +125,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
125
125
  * Removes connection interface attributes by environment
126
126
  */
127
127
  deleteConnectionInterfaceAttributesFromEnvironment = this.mutation(connectionInterfaceControllerdeleteConnectionInterfaceAttributesFromEnvironment)
128
-
128
+
129
129
  /**
130
130
  * Updates the attributes of a connection interface
131
131
  */
@@ -164,27 +164,27 @@ class WorkspaceClient extends ReactQueryNetworkClient {
164
164
  * Gets all embedded links from a workspace
165
165
  */
166
166
  allEmbeddedLinksInWorkspace = this.query(workspaceEmbeddedLinkControllergetEmbeddedLinks)
167
-
167
+
168
168
  /**
169
169
  * Creates an embedded link in a workspace
170
170
  */
171
171
  createEmbeddedLinkInWorkspace = this.mutation(workspaceEmbeddedLinkControllersave)
172
-
172
+
173
173
  /**
174
174
  * Deletes an embedded link from a workspace
175
175
  */
176
176
  deleteEmbeddedLinkFromWorkspace = this.mutation(workspaceEmbeddedLinkControllerdelete)
177
-
177
+
178
178
  /**
179
179
  * Updates an embedded link from a workspace
180
180
  */
181
181
  updateEmbeddedLinkInWorkspace = this.mutation(workspaceEmbeddedLinkControllerupdate)
182
-
182
+
183
183
  /**
184
184
  * Updates all embedded links from a workspace
185
185
  */
186
186
  updateAllEmbeddedLinksInWorkspace = this.mutation(workspaceEmbeddedLinkControllerupsertBatch)
187
-
187
+
188
188
  /**
189
189
  * Gets an embedded link from an application
190
190
  */
@@ -194,7 +194,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
194
194
  * Gets all embedded links from an application
195
195
  */
196
196
  allEmbeddedLinksInApplication = this.query(applicationEmbeddedLinkControllergetEmbeddedLinks)
197
-
197
+
198
198
  /**
199
199
  * Creates an embedded link in an application
200
200
  */
@@ -209,12 +209,12 @@ class WorkspaceClient extends ReactQueryNetworkClient {
209
209
  * Updates an embedded link in an application
210
210
  */
211
211
  updateEmbeddedLinkInApplication = this.mutation(applicationEmbeddedLinkControllerupdate)
212
-
212
+
213
213
  /**
214
214
  * Updates all embedded links in an application
215
215
  */
216
216
  updateAllEmbeddedLinksInApplication = this.mutation(applicationEmbeddedLinkControllerupsertBatch)
217
-
217
+
218
218
  /**
219
219
  * Gets all workspaces
220
220
  */
@@ -237,45 +237,45 @@ class WorkspaceClient extends ReactQueryNetworkClient {
237
237
  /**
238
238
  * Updates a workspace
239
239
  */
240
- updateWorkspace = this.mutation(workspaceControllerupdate)
241
-
240
+ updateWorkspace = this.mutation(workspaceControllerupdate)
241
+
242
242
  //App and infra
243
243
  /**
244
244
  * Gets all applications in a Workspace
245
245
  */
246
- applications = this.query(applicationControllergetApplications)
246
+ applications = this.query(workspaceApplicationControllergetApplications)
247
247
  /**
248
248
  * Gets an application
249
249
  */
250
- application = this.query(applicationControllergetApplication)
250
+ application = this.query(workspaceApplicationControllergetApplication)
251
251
 
252
252
  /**
253
253
  * Gets the dependencies of an application
254
254
  */
255
- applicationDependencies = this.query(applicationControllergetDependencyTree)
255
+ applicationDependencies = this.query(workspaceApplicationControllergetDependencyTree)
256
256
  /**
257
257
  * Gets all shared infra in a Workspace
258
258
  */
259
- allSharedInfra = this.query(sharedInfrastructureControllergetAllSharedInfrastructure)
259
+ allSharedInfra = this.query(workspaceSharedInfrastructureControllergetAllSharedInfrastructure)
260
260
  /**
261
261
  * Gets a shared infra
262
262
  */
263
- sharedInfra = this.query(sharedInfrastructureControllergetSharedInfrastructure)
263
+ sharedInfra = this.query(workspaceSharedInfrastructureControllergetSharedInfrastructure)
264
264
 
265
265
  /**
266
266
  * Gets the dependencies of a shared infra
267
267
  */
268
- sharedInfraDependencies = this.query(sharedInfrastructureControllergetDependencyTree)
269
-
268
+ sharedInfraDependencies = this.query(workspaceSharedInfrastructureControllergetDependencyTree)
269
+
270
270
  /**
271
271
  * Updates an application
272
272
  */
273
- updateApplication = this.mutation(applicationControllerupdate)
273
+ updateApplication = this.mutation(workspaceApplicationControllerupdate)
274
274
 
275
275
  /**
276
276
  * Updates a shared infra
277
277
  */
278
- updateInfra = this.mutation(sharedInfrastructureControllerupdate)
278
+ updateInfra = this.mutation(workspaceSharedInfrastructureControllerupdate)
279
279
 
280
280
  // Workflow
281
281
  /**
@@ -296,7 +296,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
296
296
  deleteAccountWorkflow = this.mutation(workflowAccountControllerdeleteAccountWorkflow)
297
297
 
298
298
  // Variables Account
299
-
299
+
300
300
  /**
301
301
  * Find all account variables
302
302
  */
@@ -321,7 +321,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
321
321
  * Delete account variable
322
322
  */
323
323
  deleteAccountVariable = this.mutation(accountVariableControllerdelete)
324
-
324
+
325
325
  // Variables Workspace
326
326
 
327
327
  /**
@@ -336,7 +336,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
336
336
  * Updates workspace variable based on existing account variable
337
337
  */
338
338
  updateWorkspaceVariable = this.mutation(workspaceVariableV2Controllerupsert)
339
-
339
+
340
340
  //Links
341
341
  /**
342
342
  * Gets shared infra links
@@ -390,7 +390,7 @@ class WorkspaceClient extends ReactQueryNetworkClient {
390
390
  * Updates infra links visibility
391
391
  */
392
392
  updateLinkVisibilityInInfra = this.mutation(sharedInfraLinkControllerupdateLinksVisibility)
393
-
393
+
394
394
  /**
395
395
  * Gets stacks in a workspace. This fn is only used for permission purposes.
396
396
  */
@@ -426,23 +426,23 @@ class WorkspaceClient extends ReactQueryNetworkClient {
426
426
  /**
427
427
  * Deletes a workspace . This fn is only used for permission purposes.
428
428
  */
429
- deleteWorkspace = this.query(workspaceControllerdelete) as OperationObject<Parameters<typeof workspaceControllerdelete>[0]>
429
+ deleteWorkspace = this.query(workspaceControllerdelete) as OperationObject<Parameters<typeof workspaceControllerdelete>[0]>
430
430
  /**
431
431
  * Deletes an application. This fn is only used for permission purposes.
432
432
  */
433
- deleteApplication = this.query(applicationControllerdeleteApplication) as OperationObject<Parameters<typeof applicationControllerdeleteApplication>[0]>
433
+ deleteApplication = this.query(workspaceApplicationControllerdeleteApplication) as OperationObject<Parameters<typeof workspaceApplicationControllerdeleteApplication>[0]>
434
434
  /**
435
435
  * Deletes an infra. This fn is only used for permission purposes.
436
436
  */
437
- deleteInfra = this.query(sharedInfrastructureControllerdeleteSharedInfra) as OperationObject<Parameters<typeof sharedInfrastructureControllerdeleteSharedInfra>[0]>
437
+ deleteInfra = this.query(workspaceSharedInfrastructureControllerdeleteSharedInfra) as OperationObject<Parameters<typeof workspaceSharedInfrastructureControllerdeleteSharedInfra>[0]>
438
438
  /**
439
439
  * Gets the detail of an application. This fn is only used for permission purposes.
440
440
  */
441
- applicationDetail = this.query(applicationControllergetApplication) as OperationObject<Parameters<typeof applicationControllergetApplication>[0]>
441
+ applicationDetail = this.query(workspaceApplicationControllergetApplication) as OperationObject<Parameters<typeof workspaceApplicationControllergetApplication>[0]>
442
442
  /**
443
443
  * Gets the detail of an infra. This fn is only used for permission purposes.
444
444
  */
445
- infraDetail = this.query(sharedInfrastructureControllergetSharedInfrastructure) as OperationObject<Parameters<typeof sharedInfrastructureControllergetSharedInfrastructure>[0]>
445
+ infraDetail = this.query(workspaceSharedInfrastructureControllergetSharedInfrastructure) as OperationObject<Parameters<typeof workspaceSharedInfrastructureControllergetSharedInfrastructure>[0]>
446
446
  }
447
447
 
448
448
  export const workspaceClient = new WorkspaceClient()
package/src/index.ts CHANGED
@@ -27,5 +27,5 @@ export { NetworkClient } from './network/NetworkClient'
27
27
  export { queryClient } from './network/react-query-client'
28
28
  export { OperationResult, OperationVariables, UseQueryObjectOptions } from './network/types'
29
29
  export { StreamedJson } from './utils/StreamedJson'
30
- export { useCanViewOrg } from './utils/use-can-view-org'
31
30
  export { useExtendedList } from './utils/use-extended-list'
31
+
@@ -1,4 +0,0 @@
1
- export declare const useCanViewOrg: ({ accountSlug }: {
2
- accountSlug: string;
3
- }) => boolean | undefined;
4
- //# sourceMappingURL=use-can-view-org.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-can-view-org.d.ts","sourceRoot":"","sources":["../../src/utils/use-can-view-org.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,oBAAqB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,wBAwBrE,CAAA"}
@@ -1,24 +0,0 @@
1
- import { accountClient } from '../client/account.js';
2
- import { contentClient } from '../client/content.js';
3
- import { insightsClient } from '../client/insights.js';
4
- import { workspaceClient } from '../client/workspace.js';
5
- export const useCanViewOrg = ({ accountSlug }) => {
6
- const [canCreateEnvironments] = workspaceClient.createEnvironment.useAllowed();
7
- const [canViewWorkflows] = workspaceClient.accountWorkflows.useAllowed();
8
- const [canViewVariables] = workspaceClient.accountVariables.useAllowed();
9
- const [canCreateScm] = accountClient.createSCMCredential.useAllowed();
10
- const [canViewPartner] = accountClient.partners.useAllowed();
11
- const [canViewAllByAccount] = contentClient.getAllStacks.useAllowed();
12
- const canViewEdp = canCreateEnvironments || canViewWorkflows || canViewVariables || canCreateScm || canViewPartner || canViewAllByAccount;
13
- const [canViewSSO] = accountClient.allSSO.useAllowed();
14
- const [canDownloadEventHistory] = insightsClient.downloadAccountData.useAllowed({ accountSlug });
15
- const [canViewServiceCredential] = accountClient.allServiceCredentials.useAllowed();
16
- const canViewIdentitySecurity = canViewSSO || canDownloadEventHistory || canViewServiceCredential;
17
- const [canViewMembers] = accountClient.allMembers.useAllowed();
18
- const [canViewRoles] = accountClient.allRoles.useAllowed();
19
- const [canViewGroups] = accountClient.allGroups.useAllowed();
20
- const canViewAccessManagement = canViewMembers || canViewRoles || canViewGroups;
21
- const canViewGeneralSettings = canViewIdentitySecurity || canViewAccessManagement;
22
- return canViewGeneralSettings || canViewEdp;
23
- };
24
- //# sourceMappingURL=use-can-view-org.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-can-view-org.js","sourceRoot":"","sources":["../../src/utils/use-can-view-org.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,WAAW,EAA2B,EAAE,EAAE;IACxE,MAAM,CAAC,qBAAqB,CAAC,GAAG,eAAe,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAA;IAC9E,MAAM,CAAC,gBAAgB,CAAC,GAAG,eAAe,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAA;IACxE,MAAM,CAAC,gBAAgB,CAAC,GAAG,eAAe,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAA;IACxE,MAAM,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAA;IACrE,MAAM,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IAC5D,MAAM,CAAC,mBAAmB,CAAC,GAAG,aAAa,CAAC,YAAY,CAAC,UAAU,EAAE,CAAA;IACrE,MAAM,UAAU,GAAG,qBAAqB,IAAI,gBAAgB,IAAI,gBAAgB,IAAI,YAAY,IAAI,cAAc,IAAI,mBAAmB,CAAA;IAEzI,MAAM,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,UAAU,EAAE,CAAA;IACtD,MAAM,CAAC,uBAAuB,CAAC,GAAG,cAAc,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,WAAW,EAAE,CAAC,CAAA;IAChG,MAAM,CAAC,wBAAwB,CAAC,GAAG,aAAa,CAAC,qBAAqB,CAAC,UAAU,EAAE,CAAA;IAEnF,MAAM,uBAAuB,GAAG,UAAU,IAAI,uBAAuB,IAAI,wBAAwB,CAAA;IAEjG,MAAM,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,UAAU,EAAE,CAAA;IAC9D,MAAM,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IAC1D,MAAM,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,SAAS,CAAC,UAAU,EAAE,CAAA;IAE5D,MAAM,uBAAuB,GAAG,cAAc,IAAI,YAAY,IAAI,aAAa,CAAA;IAE/E,MAAM,sBAAsB,GAAG,uBAAuB,IAAI,uBAAuB,CAAA;IAEjF,OAAO,sBAAsB,IAAI,UAAU,CAAA;AAC7C,CAAC,CAAA"}
@@ -1,30 +0,0 @@
1
- import { accountClient } from '../client/account'
2
- import { contentClient } from '../client/content'
3
- import { insightsClient } from '../client/insights'
4
- import { workspaceClient } from '../client/workspace'
5
-
6
- export const useCanViewOrg = ({ accountSlug }: { accountSlug: string }) => {
7
- const [canCreateEnvironments] = workspaceClient.createEnvironment.useAllowed()
8
- const [canViewWorkflows] = workspaceClient.accountWorkflows.useAllowed()
9
- const [canViewVariables] = workspaceClient.accountVariables.useAllowed()
10
- const [canCreateScm] = accountClient.createSCMCredential.useAllowed()
11
- const [canViewPartner] = accountClient.partners.useAllowed()
12
- const [canViewAllByAccount] = contentClient.getAllStacks.useAllowed()
13
- const canViewEdp = canCreateEnvironments || canViewWorkflows || canViewVariables || canCreateScm || canViewPartner || canViewAllByAccount
14
-
15
- const [canViewSSO] = accountClient.allSSO.useAllowed()
16
- const [canDownloadEventHistory] = insightsClient.downloadAccountData.useAllowed({ accountSlug })
17
- const [canViewServiceCredential] = accountClient.allServiceCredentials.useAllowed()
18
-
19
- const canViewIdentitySecurity = canViewSSO || canDownloadEventHistory || canViewServiceCredential
20
-
21
- const [canViewMembers] = accountClient.allMembers.useAllowed()
22
- const [canViewRoles] = accountClient.allRoles.useAllowed()
23
- const [canViewGroups] = accountClient.allGroups.useAllowed()
24
-
25
- const canViewAccessManagement = canViewMembers || canViewRoles || canViewGroups
26
-
27
- const canViewGeneralSettings = canViewIdentitySecurity || canViewAccessManagement
28
-
29
- return canViewGeneralSettings || canViewEdp
30
- }