@atlaskit/teams-client 5.4.0 → 5.6.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 (82) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/cjs/common/utils/error/isAuthError.js +1 -1
  3. package/dist/cjs/common/utils/ufo/index.js +2 -2
  4. package/dist/cjs/index.js +19 -12
  5. package/dist/cjs/services/base-client/index.js +2 -2
  6. package/dist/cjs/services/constants.js +2 -1
  7. package/dist/cjs/services/invitations-client/InvitationsClient.js +1 -1
  8. package/dist/cjs/services/sentry/utils/get-sentry-config.js +1 -1
  9. package/dist/cjs/services/teams-in-slack-client/TeamsInSlackClient.js +110 -22
  10. package/dist/cjs/services/use-query-light/useQueryLight.js +3 -3
  11. package/dist/es2019/common/utils/ari.js +1 -0
  12. package/dist/es2019/common/utils/error/index.js +1 -0
  13. package/dist/es2019/common/utils/error/isAuthError.js +1 -1
  14. package/dist/es2019/common/utils/index.js +1 -0
  15. package/dist/es2019/common/utils/permissions/index.js +1 -0
  16. package/dist/es2019/common/utils/team.js +1 -0
  17. package/dist/es2019/common/utils/ufo/index.js +2 -2
  18. package/dist/es2019/index.js +10 -3
  19. package/dist/es2019/mocks/endpoints.js +1 -0
  20. package/dist/es2019/mocks/generate-data.js +1 -0
  21. package/dist/es2019/mocks/index.js +1 -0
  22. package/dist/es2019/services/agg-client/index.js +1 -0
  23. package/dist/es2019/services/base-client/index.js +1 -1
  24. package/dist/es2019/services/constants.js +2 -1
  25. package/dist/es2019/services/hooks/use-teams-client-setup.js +1 -0
  26. package/dist/es2019/services/invitations-client/InvitationsClient.js +1 -1
  27. package/dist/es2019/services/public-api-client/index.js +1 -0
  28. package/dist/es2019/services/sentry/index.js +1 -0
  29. package/dist/es2019/services/sentry/main.js +1 -0
  30. package/dist/es2019/services/sentry/utils/get-sentry-config.js +1 -1
  31. package/dist/es2019/services/teams-in-slack-client/TeamsInSlackClient.js +51 -1
  32. package/dist/es2019/services/use-query-light/index.js +1 -0
  33. package/dist/es2019/services/use-query-light/main.js +1 -0
  34. package/dist/es2019/services/use-query-light/useQueryLight.js +1 -1
  35. package/dist/esm/common/utils/ari.js +1 -0
  36. package/dist/esm/common/utils/error/index.js +1 -0
  37. package/dist/esm/common/utils/error/isAuthError.js +1 -1
  38. package/dist/esm/common/utils/index.js +1 -0
  39. package/dist/esm/common/utils/permissions/index.js +1 -0
  40. package/dist/esm/common/utils/team.js +1 -0
  41. package/dist/esm/common/utils/ufo/index.js +2 -2
  42. package/dist/esm/index.js +10 -3
  43. package/dist/esm/mocks/endpoints.js +1 -0
  44. package/dist/esm/mocks/generate-data.js +1 -0
  45. package/dist/esm/mocks/index.js +1 -0
  46. package/dist/esm/services/agg-client/index.js +1 -0
  47. package/dist/esm/services/base-client/index.js +1 -1
  48. package/dist/esm/services/constants.js +2 -1
  49. package/dist/esm/services/hooks/use-teams-client-setup.js +1 -0
  50. package/dist/esm/services/invitations-client/InvitationsClient.js +1 -1
  51. package/dist/esm/services/public-api-client/index.js +1 -0
  52. package/dist/esm/services/sentry/index.js +1 -0
  53. package/dist/esm/services/sentry/main.js +1 -0
  54. package/dist/esm/services/sentry/utils/get-sentry-config.js +1 -1
  55. package/dist/esm/services/teams-in-slack-client/TeamsInSlackClient.js +110 -22
  56. package/dist/esm/services/use-query-light/index.js +1 -0
  57. package/dist/esm/services/use-query-light/main.js +1 -0
  58. package/dist/esm/services/use-query-light/useQueryLight.js +1 -1
  59. package/dist/types/common/utils/is-invited.d.ts +1 -1
  60. package/dist/types/common/utils/is-member.d.ts +1 -1
  61. package/dist/types/common/utils/is-non-member.d.ts +1 -1
  62. package/dist/types/common/utils/is-requesting-join.d.ts +1 -1
  63. package/dist/types/common/utils/sort-teams.d.ts +1 -1
  64. package/dist/types/index.d.ts +13 -5
  65. package/dist/types/mocks/fixed-team-memberships.d.ts +1 -1
  66. package/dist/types/mocks/random-returned-new-team-data.d.ts +1 -1
  67. package/dist/types/mocks/random-team-membership.d.ts +1 -1
  68. package/dist/types/mocks/random-team-memberships.d.ts +1 -1
  69. package/dist/types/mocks/responses.d.ts +1 -1
  70. package/dist/types/mocks/team-link.d.ts +1 -1
  71. package/dist/types/mocks/with-faker.d.ts +3 -1
  72. package/dist/types/services/agg-client/index.d.ts +3 -2
  73. package/dist/types/services/agg-client/utils/queries/team-membership-query.d.ts +1 -1
  74. package/dist/types/services/constants.d.ts +1 -1
  75. package/dist/types/services/directory-client/index.d.ts +1 -1
  76. package/dist/types/services/identity-client/IdentityClient.d.ts +1 -1
  77. package/dist/types/services/legion-client/index.d.ts +4 -2
  78. package/dist/types/services/main.d.ts +4 -2
  79. package/dist/types/services/public-api-client/PublicApiClient.d.ts +1 -1
  80. package/dist/types/services/teams-in-slack-client/TeamsInSlackClient.d.ts +20 -21
  81. package/dist/types/types/config.d.ts +1 -0
  82. package/package.json +6 -36
@@ -28,7 +28,7 @@ export function getSentryConfig(options) {
28
28
  ...DEFAULT_SENTRY_CONFIG,
29
29
  // Standalone __VERSION__ is set from `bin/set-release-version.sh`
30
30
  // when building to deploy to production
31
- release: `${"@atlaskit/teams-client"}@${"5.3.0"}` ||
31
+ release: `${"@atlaskit/teams-client"}@${"5.5.0"}` ||
32
32
  // @ts-ignore Jira - window.BUILD_KEY
33
33
  window.BUILD_KEY || ( // @ts-ignore Confluence - window.__buildInfo
34
34
  (_window$__buildInfo = window.__buildInfo) === null || _window$__buildInfo === void 0 ? void 0 : _window$__buildInfo.FRONTEND_VERSION) || '---',
@@ -1,8 +1,22 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
2
+ import { SLOIgnoreError } from '../../common/utils/error/SLOIgnoreError';
1
3
  import { DEFAULT_CONFIG } from '../constants';
2
4
  import { RestClient } from '../rest-client';
5
+ import { redirectCount } from '../rest-client/utils/redirect-count';
6
+ const GLOBAL_EDGE_ORIGIN = new URL(DEFAULT_CONFIG.teamsInSlackServiceUrl).origin;
3
7
  const defaultConfig = {
4
- serviceUrl: `${DEFAULT_CONFIG.stargateRoot}/teamsslack/api/team`
8
+ get serviceUrl() {
9
+ return fg('ptc-onboard-teams-slack-app-to-global-edge-url') ? DEFAULT_CONFIG.teamsInSlackServiceUrl : `${DEFAULT_CONFIG.stargateRoot}/teamsslack/api/team`;
10
+ }
5
11
  };
12
+
13
+ // Shared in-flight probe: concurrent callers coalesce onto one fetch rather
14
+ // than each firing their own and racing on the flag.
15
+ let staffyAuthProbe = null;
16
+
17
+ // Prevents an infinite redirect loop if Okta completes but auth still fails.
18
+ // Resets on full page reload — correct, since a reload after login should retry.
19
+ let staffyAuthAttempted = false;
6
20
  export class TeamsInSlackClient extends RestClient {
7
21
  constructor(config = {}) {
8
22
  super({
@@ -10,19 +24,55 @@ export class TeamsInSlackClient extends RestClient {
10
24
  ...config
11
25
  });
12
26
  }
27
+
28
+ /**
29
+ * Pre-flight auth probe for Staffy Global Edge calls (COMMIT-27483).
30
+ * Fetches /api/authping with credentials:'include'. On failure (302→Okta),
31
+ * navigates to /staffy/login?return_to=<current URL> for top-level Okta SSO.
32
+ * No-op when the gate is OFF (Stargate path).
33
+ */
34
+ async ensureStaffyAuth() {
35
+ if (!fg('ptc-onboard-teams-slack-app-to-global-edge-url')) {
36
+ return;
37
+ }
38
+ staffyAuthProbe ??= fetch(`${GLOBAL_EDGE_ORIGIN}/api/authping`, {
39
+ credentials: 'include'
40
+ }).then(r => r.ok).catch(() => false).finally(() => {
41
+ staffyAuthProbe = null;
42
+ });
43
+ const authenticated = await staffyAuthProbe;
44
+ if (authenticated) {
45
+ staffyAuthAttempted = false;
46
+ return;
47
+ }
48
+ if (staffyAuthAttempted) {
49
+ // Already redirected once — let the call proceed and surface the error.
50
+ return;
51
+ }
52
+ staffyAuthAttempted = true;
53
+ redirectCount.increment();
54
+ const returnTo = encodeURIComponent(window.location.href);
55
+ window.location.assign(`${GLOBAL_EDGE_ORIGIN}/staffy/login?return_to=${returnTo}`);
56
+ throw new SLOIgnoreError({
57
+ message: 'Redirecting to Staffy login'
58
+ });
59
+ }
13
60
  async getTeamInSlack(teamId, teamName) {
61
+ await this.ensureStaffyAuth();
14
62
  return this.getResource(`/${teamId}?teamName=${encodeURIComponent(teamName)}`).then(response => ({
15
63
  id: teamId,
16
64
  ...response
17
65
  }));
18
66
  }
19
67
  async disconnectTeamInSlack(teamId) {
68
+ await this.ensureStaffyAuth();
20
69
  return this.deleteResource(`/${teamId}`).then(response => ({
21
70
  id: teamId,
22
71
  ...response
23
72
  }));
24
73
  }
25
74
  async updateTeamInSlack(teamId, channelId, usergroupHandle) {
75
+ await this.ensureStaffyAuth();
26
76
  return this.postResource(`/${teamId}?channel=${channelId}&groupName=${usergroupHandle}`).then(response => ({
27
77
  id: teamId,
28
78
  ...response
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * @deprecated Use `import { useLazyQueryLight } from '@atlaskit/teams-client/use-query-light/use-lazy-query-light'` instead.
4
4
  */
5
+
5
6
  export { useLazyQueryLight } from './useLazyQueryLight';
6
7
  /**
7
8
  * @deprecated Use `import { useQueryLight } from '@atlaskit/teams-client/use-query-light/use-query-light'` instead.
@@ -3,6 +3,7 @@
3
3
  /**
4
4
  * @deprecated Use `import { useQueryLight } from '@atlaskit/teams-client/use-query-light/use-query-light'` instead.
5
5
  */
6
+
6
7
  export { useQueryLight } from './useQueryLight';
7
8
  /**
8
9
  * @deprecated Use `import { useLazyQueryLight } from '@atlaskit/teams-client/use-query-light/use-lazy-query-light'` instead.
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { print } from 'graphql';
3
3
  import isEqual from 'lodash/isEqual';
4
4
  import { fetchWithExponentialBackoff } from '../../common/utils/http';
5
- import { logException } from '../sentry';
5
+ import { logException } from '../sentry/logException';
6
6
  import { UseQueryLightError } from './UseQueryLightError';
7
7
  const transformError = ({
8
8
  error,
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * @deprecated Use `import { isUserARI } from '@atlaskit/teams-client/is-user-ari'` instead.
4
4
  */
5
+
5
6
  export { isUserARI } from './is-user-ari';
6
7
  /**
7
8
  * @deprecated Use `import { toUserId } from '@atlaskit/teams-client/to-user-id'` instead.
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
2
+
2
3
  export var ErrorCategory = /*#__PURE__*/function (ErrorCategory) {
3
4
  ErrorCategory["NotFound"] = "NotFound";
4
5
  ErrorCategory["NotPermitted"] = "NotPermitted";
@@ -1,5 +1,5 @@
1
- import { isErrorStatusCode } from './isErrorStatusCode';
2
1
  import { StatusCode } from './index';
2
+ import { isErrorStatusCode } from './isErrorStatusCode';
3
3
  export function isAuthError(error) {
4
4
  return isErrorStatusCode(StatusCode.UNAUTHORIZED, error) || isErrorStatusCode(StatusCode.FORBIDDEN, error);
5
5
  }
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * @deprecated Use `import { sortMembersByType } from '@atlaskit/teams-client/sort-teams'` instead.
4
4
  */
5
+
5
6
  export { sortMembersByType } from './sort-teams';
6
7
  /**
7
8
  * @deprecated Use `import { isInvited } from '@atlaskit/teams-client/is-invited'` instead.
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * @deprecated Use `import { hasPermissionForAction } from '@atlaskit/teams-client/has-permission-for-action'` instead.
4
4
  */
5
+
5
6
  export { hasPermissionForAction } from './has-permission-for-action';
6
7
  /**
7
8
  * @deprecated Use `import { hasPermission } from '@atlaskit/teams-client/has-permission'` instead.
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * @deprecated Use `import { isInvited } from '@atlaskit/teams-client/is-invited'` instead.
4
4
  */
5
+
5
6
  export { isInvited } from './is-invited';
6
7
  /**
7
8
  * @deprecated Use `import { isNonMember } from '@atlaskit/teams-client/is-non-member'` instead.
@@ -49,7 +49,7 @@ export var TeamsUFOExperience = /*#__PURE__*/function (_UFOExperience) {
49
49
  return _superPropGet(TeamsUFOExperience, "failure", this, 3)([{
50
50
  metadata: {
51
51
  error: createErrorMetadata(error),
52
- packageVersion: "5.3.0",
52
+ packageVersion: "5.5.0",
53
53
  packageName: "@atlaskit/teams-client"
54
54
  }
55
55
  }]);
@@ -57,7 +57,7 @@ export var TeamsUFOExperience = /*#__PURE__*/function (_UFOExperience) {
57
57
  return _superPropGet(TeamsUFOExperience, "failure", this, 3)([{
58
58
  metadata: {
59
59
  error: 'unknown error',
60
- packageVersion: "5.3.0",
60
+ packageVersion: "5.5.0",
61
61
  packageName: "@atlaskit/teams-client"
62
62
  }
63
63
  }]);
package/dist/esm/index.js CHANGED
@@ -7,7 +7,8 @@ export { useTeamsClientSetupNext } from './services/hooks/use-teams-client-setup
7
7
  export { useTeamsClientSetup } from './services/hooks/use-teams-client-setup';
8
8
 
9
9
  // /permissions
10
- export { AllTeamActions, hasPermission } from './common/utils/permissions';
10
+ export { AllTeamActions } from './common/utils/permissions/types';
11
+ export { hasPermission } from './common/utils/permissions/has-permission';
11
12
  // /sentry
12
13
  export { initialiseSentry } from './services/sentry/utils/initialise-sentry';
13
14
  export { logException } from './services/sentry/logException';
@@ -16,9 +17,15 @@ export { logInfoMessage } from './services/sentry/logInfoMessage';
16
17
  export { userInfoProvider, UserInfoProvider } from './services/user-info-provider/main';
17
18
 
18
19
  // /utils
19
- export { sortMembersByType, isInvited, isMember, isNonMember, isRequestingJoin } from './common/utils';
20
+ export { sortMembersByType } from './common/utils/sort-teams';
21
+ export { isInvited } from './common/utils/is-invited';
22
+ export { isMember } from './common/utils/is-member';
23
+ export { isNonMember } from './common/utils/is-non-member';
24
+ export { isRequestingJoin } from './common/utils/is-requesting-join';
20
25
  export { toTeamARI } from './common/utils/to-team-ari';
21
26
  export { toTeamId } from './common/utils/to-team-id';
22
27
  export { toUserARI } from './common/utils/to-user-ari';
23
28
  export { toUserId } from './common/utils/to-user-id';
24
- export { useLazyQueryLight, useQueryLight, UseQueryLightError } from './services/use-query-light';
29
+ export { useLazyQueryLight } from './services/use-query-light/useLazyQueryLight';
30
+ export { useQueryLight } from './services/use-query-light/useQueryLight';
31
+ export { UseQueryLightError } from './services/use-query-light/UseQueryLightError';
@@ -3,6 +3,7 @@
3
3
  /**
4
4
  * @deprecated Use `import { mockTeamsClientEndpoints } from '@atlaskit/teams-client/mock-teams-client-endpoints'` instead.
5
5
  */
6
+
6
7
  export { mockTeamsClientEndpoints } from './mock-teams-client-endpoints';
7
8
  /**
8
9
  * @deprecated Use `import { mockTeamsClientRequestingToJoinEndpoints } from '@atlaskit/teams-client/mock-teams-client-requesting-to-join-endpoints'` instead.
@@ -3,6 +3,7 @@
3
3
  /**
4
4
  * @deprecated Use `import { randomTeamMembership } from '@atlaskit/teams-client/random-team-membership'` instead.
5
5
  */
6
+
6
7
  export { randomTeamMembership } from './random-team-membership';
7
8
  /**
8
9
  * @deprecated Use `import { randomTeamMemberships } from '@atlaskit/teams-client/random-team-memberships'` instead.
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * @deprecated Use `import { mockTeamsClientAdminEndpoints } from '@atlaskit/teams-client/mock-teams-client-admin-endpoints'` instead.
4
4
  */
5
+
5
6
  export { mockTeamsClientAdminEndpoints } from './mock-teams-client-admin-endpoints';
6
7
  /**
7
8
  * @deprecated Use `import { mockTeamsClientEndpoints } from '@atlaskit/teams-client/mock-teams-client-endpoints'` instead.
@@ -11,6 +11,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
11
11
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
13
  /* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
14
+
14
15
  import { toTeamARI } from '../../common/utils/to-team-ari';
15
16
  import { toUserId } from '../../common/utils/to-user-id';
16
17
  import { DEFAULT_CONFIG } from '../constants';
@@ -3,7 +3,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import { logException } from '../sentry';
6
+ import { logException } from '../sentry/logException';
7
7
  export var BaseClient = /*#__PURE__*/function () {
8
8
  function BaseClient(config) {
9
9
  var _this = this;
@@ -3,5 +3,6 @@ export var DEFAULT_CONFIG = {
3
3
  permsServiceUrl: '/gateway/api/permissions',
4
4
  publicApiRoot: '/gateway/api/public',
5
5
  invitationsServiceUrl: '/gateway/api/invitations',
6
- collaborationGraphUrl: '/gateway/api/collaboration'
6
+ collaborationGraphUrl: '/gateway/api/collaboration',
7
+ teamsInSlackServiceUrl: 'https://teams-slack-app.services.atlassian.com/api/team'
7
8
  };
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
2
+
2
3
  import { useTeamsClientSetupNext } from './use-teams-client-setup-next';
3
4
 
4
5
  /**
@@ -8,8 +8,8 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  import { RestClient } from '../rest-client';
11
- import { removeDuplicateRecommendations } from './utils';
12
11
  import { PRODUCT_JOIN_OR_REQUEST_BULK, PRODUCT_RECCOMENDATIONS } from './index';
12
+ import { removeDuplicateRecommendations } from './utils';
13
13
  var ALL_SUPPORTED_PRODUCTS = ['confluence', 'jira', 'jira-core', 'jira-servicedesk', 'jira-software', 'jira-incident-manager', 'jira-product-discovery', 'opsgenie', 'statuspage', 'avocado', 'townsquare', 'compass', 'avp', 'beacon', 'mercury'];
14
14
  export var InvitationsClient = /*#__PURE__*/function (_RestClient) {
15
15
  function InvitationsClient(serviceUrl, config) {
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @repo/internal/deprecations/deprecation-ticket-required -- VOLTC-139 tracks removal of these deprecated re-export shims. */
2
+
2
3
  import { DEFAULT_CONFIG } from '../constants';
3
4
  import { PublicApiClient } from './PublicApiClient';
4
5
 
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * @deprecated Use `import { addBreadcrumb } from '@atlaskit/teams-client/add-breadcrumb'` instead.
4
4
  */
5
+
5
6
  export { addBreadcrumb } from './addBreadcrumb';
6
7
  /**
7
8
  * @deprecated Use `import { createErrorHandler } from '@atlaskit/teams-client/create-error-handler'` instead.
@@ -4,6 +4,7 @@
4
4
  /**
5
5
  * @deprecated Use `import { logException } from '@atlaskit/teams-client/log-exception'` instead.
6
6
  */
7
+
7
8
  export { logException } from './logException';
8
9
  /**
9
10
  * @deprecated Use `import { logErrorMessage } from '@atlaskit/teams-client/log-error-message'` instead.
@@ -29,7 +29,7 @@ export function getSentryConfig(options) {
29
29
  return _objectSpread(_objectSpread(_objectSpread({}, otherOptions), DEFAULT_SENTRY_CONFIG), {}, {
30
30
  // Standalone __VERSION__ is set from `bin/set-release-version.sh`
31
31
  // when building to deploy to production
32
- release: "".concat("@atlaskit/teams-client", "@").concat("5.3.0") ||
32
+ release: "".concat("@atlaskit/teams-client", "@").concat("5.5.0") ||
33
33
  // @ts-ignore Jira - window.BUILD_KEY
34
34
  window.BUILD_KEY || ( // @ts-ignore Confluence - window.__buildInfo
35
35
  (_window$__buildInfo = window.__buildInfo) === null || _window$__buildInfo === void 0 ? void 0 : _window$__buildInfo.FRONTEND_VERSION) || '---',
@@ -10,35 +10,117 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
10
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
11
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
14
+ import { SLOIgnoreError } from '../../common/utils/error/SLOIgnoreError';
13
15
  import { DEFAULT_CONFIG } from '../constants';
14
16
  import { RestClient } from '../rest-client';
17
+ import { redirectCount } from '../rest-client/utils/redirect-count';
18
+ var GLOBAL_EDGE_ORIGIN = new URL(DEFAULT_CONFIG.teamsInSlackServiceUrl).origin;
15
19
  var defaultConfig = {
16
- serviceUrl: "".concat(DEFAULT_CONFIG.stargateRoot, "/teamsslack/api/team")
20
+ get serviceUrl() {
21
+ return fg('ptc-onboard-teams-slack-app-to-global-edge-url') ? DEFAULT_CONFIG.teamsInSlackServiceUrl : "".concat(DEFAULT_CONFIG.stargateRoot, "/teamsslack/api/team");
22
+ }
17
23
  };
24
+
25
+ // Shared in-flight probe: concurrent callers coalesce onto one fetch rather
26
+ // than each firing their own and racing on the flag.
27
+ var staffyAuthProbe = null;
28
+
29
+ // Prevents an infinite redirect loop if Okta completes but auth still fails.
30
+ // Resets on full page reload — correct, since a reload after login should retry.
31
+ var staffyAuthAttempted = false;
18
32
  export var TeamsInSlackClient = /*#__PURE__*/function (_RestClient) {
19
33
  function TeamsInSlackClient() {
20
34
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
35
  _classCallCheck(this, TeamsInSlackClient);
22
36
  return _callSuper(this, TeamsInSlackClient, [_objectSpread(_objectSpread({}, defaultConfig), config)]);
23
37
  }
38
+
39
+ /**
40
+ * Pre-flight auth probe for Staffy Global Edge calls (COMMIT-27483).
41
+ * Fetches /api/authping with credentials:'include'. On failure (302→Okta),
42
+ * navigates to /staffy/login?return_to=<current URL> for top-level Okta SSO.
43
+ * No-op when the gate is OFF (Stargate path).
44
+ */
24
45
  _inherits(TeamsInSlackClient, _RestClient);
25
46
  return _createClass(TeamsInSlackClient, [{
26
- key: "getTeamInSlack",
27
- value: function () {
28
- var _getTeamInSlack = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(teamId, teamName) {
47
+ key: "ensureStaffyAuth",
48
+ value: (function () {
49
+ var _ensureStaffyAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
50
+ var authenticated, returnTo;
29
51
  return _regeneratorRuntime.wrap(function (_context) {
30
52
  while (1) switch (_context.prev = _context.next) {
31
53
  case 0:
32
- return _context.abrupt("return", this.getResource("/".concat(teamId, "?teamName=").concat(encodeURIComponent(teamName))).then(function (response) {
54
+ if (fg('ptc-onboard-teams-slack-app-to-global-edge-url')) {
55
+ _context.next = 1;
56
+ break;
57
+ }
58
+ return _context.abrupt("return");
59
+ case 1:
60
+ staffyAuthProbe !== null && staffyAuthProbe !== void 0 ? staffyAuthProbe : staffyAuthProbe = fetch("".concat(GLOBAL_EDGE_ORIGIN, "/api/authping"), {
61
+ credentials: 'include'
62
+ }).then(function (r) {
63
+ return r.ok;
64
+ }).catch(function () {
65
+ return false;
66
+ }).finally(function () {
67
+ staffyAuthProbe = null;
68
+ });
69
+ _context.next = 2;
70
+ return staffyAuthProbe;
71
+ case 2:
72
+ authenticated = _context.sent;
73
+ if (!authenticated) {
74
+ _context.next = 3;
75
+ break;
76
+ }
77
+ staffyAuthAttempted = false;
78
+ return _context.abrupt("return");
79
+ case 3:
80
+ if (!staffyAuthAttempted) {
81
+ _context.next = 4;
82
+ break;
83
+ }
84
+ return _context.abrupt("return");
85
+ case 4:
86
+ staffyAuthAttempted = true;
87
+ redirectCount.increment();
88
+ returnTo = encodeURIComponent(window.location.href);
89
+ window.location.assign("".concat(GLOBAL_EDGE_ORIGIN, "/staffy/login?return_to=").concat(returnTo));
90
+ throw new SLOIgnoreError({
91
+ message: 'Redirecting to Staffy login'
92
+ });
93
+ case 5:
94
+ case "end":
95
+ return _context.stop();
96
+ }
97
+ }, _callee);
98
+ }));
99
+ function ensureStaffyAuth() {
100
+ return _ensureStaffyAuth.apply(this, arguments);
101
+ }
102
+ return ensureStaffyAuth;
103
+ }())
104
+ }, {
105
+ key: "getTeamInSlack",
106
+ value: function () {
107
+ var _getTeamInSlack = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(teamId, teamName) {
108
+ return _regeneratorRuntime.wrap(function (_context2) {
109
+ while (1) switch (_context2.prev = _context2.next) {
110
+ case 0:
111
+ _context2.next = 1;
112
+ return this.ensureStaffyAuth();
113
+ case 1:
114
+ return _context2.abrupt("return", this.getResource("/".concat(teamId, "?teamName=").concat(encodeURIComponent(teamName))).then(function (response) {
33
115
  return _objectSpread({
34
116
  id: teamId
35
117
  }, response);
36
118
  }));
37
- case 1:
119
+ case 2:
38
120
  case "end":
39
- return _context.stop();
121
+ return _context2.stop();
40
122
  }
41
- }, _callee, this);
123
+ }, _callee2, this);
42
124
  }));
43
125
  function getTeamInSlack(_x, _x2) {
44
126
  return _getTeamInSlack.apply(this, arguments);
@@ -48,20 +130,23 @@ export var TeamsInSlackClient = /*#__PURE__*/function (_RestClient) {
48
130
  }, {
49
131
  key: "disconnectTeamInSlack",
50
132
  value: function () {
51
- var _disconnectTeamInSlack = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(teamId) {
52
- return _regeneratorRuntime.wrap(function (_context2) {
53
- while (1) switch (_context2.prev = _context2.next) {
133
+ var _disconnectTeamInSlack = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(teamId) {
134
+ return _regeneratorRuntime.wrap(function (_context3) {
135
+ while (1) switch (_context3.prev = _context3.next) {
54
136
  case 0:
55
- return _context2.abrupt("return", this.deleteResource("/".concat(teamId)).then(function (response) {
137
+ _context3.next = 1;
138
+ return this.ensureStaffyAuth();
139
+ case 1:
140
+ return _context3.abrupt("return", this.deleteResource("/".concat(teamId)).then(function (response) {
56
141
  return _objectSpread({
57
142
  id: teamId
58
143
  }, response);
59
144
  }));
60
- case 1:
145
+ case 2:
61
146
  case "end":
62
- return _context2.stop();
147
+ return _context3.stop();
63
148
  }
64
- }, _callee2, this);
149
+ }, _callee3, this);
65
150
  }));
66
151
  function disconnectTeamInSlack(_x3) {
67
152
  return _disconnectTeamInSlack.apply(this, arguments);
@@ -71,20 +156,23 @@ export var TeamsInSlackClient = /*#__PURE__*/function (_RestClient) {
71
156
  }, {
72
157
  key: "updateTeamInSlack",
73
158
  value: function () {
74
- var _updateTeamInSlack = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(teamId, channelId, usergroupHandle) {
75
- return _regeneratorRuntime.wrap(function (_context3) {
76
- while (1) switch (_context3.prev = _context3.next) {
159
+ var _updateTeamInSlack = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(teamId, channelId, usergroupHandle) {
160
+ return _regeneratorRuntime.wrap(function (_context4) {
161
+ while (1) switch (_context4.prev = _context4.next) {
77
162
  case 0:
78
- return _context3.abrupt("return", this.postResource("/".concat(teamId, "?channel=").concat(channelId, "&groupName=").concat(usergroupHandle)).then(function (response) {
163
+ _context4.next = 1;
164
+ return this.ensureStaffyAuth();
165
+ case 1:
166
+ return _context4.abrupt("return", this.postResource("/".concat(teamId, "?channel=").concat(channelId, "&groupName=").concat(usergroupHandle)).then(function (response) {
79
167
  return _objectSpread({
80
168
  id: teamId
81
169
  }, response);
82
170
  }));
83
- case 1:
171
+ case 2:
84
172
  case "end":
85
- return _context3.stop();
173
+ return _context4.stop();
86
174
  }
87
- }, _callee3, this);
175
+ }, _callee4, this);
88
176
  }));
89
177
  function updateTeamInSlack(_x4, _x5, _x6) {
90
178
  return _updateTeamInSlack.apply(this, arguments);
@@ -2,6 +2,7 @@
2
2
  /**
3
3
  * @deprecated Use `import { useLazyQueryLight } from '@atlaskit/teams-client/use-query-light/use-lazy-query-light'` instead.
4
4
  */
5
+
5
6
  export { useLazyQueryLight } from './useLazyQueryLight';
6
7
  /**
7
8
  * @deprecated Use `import { useQueryLight } from '@atlaskit/teams-client/use-query-light/use-query-light'` instead.
@@ -3,6 +3,7 @@
3
3
  /**
4
4
  * @deprecated Use `import { useQueryLight } from '@atlaskit/teams-client/use-query-light/use-query-light'` instead.
5
5
  */
6
+
6
7
  export { useQueryLight } from './useQueryLight';
7
8
  /**
8
9
  * @deprecated Use `import { useLazyQueryLight } from '@atlaskit/teams-client/use-query-light/use-lazy-query-light'` instead.
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
8
8
  import { print } from 'graphql';
9
9
  import isEqual from 'lodash/isEqual';
10
10
  import { fetchWithExponentialBackoff } from '../../common/utils/http';
11
- import { logException } from '../sentry';
11
+ import { logException } from '../sentry/logException';
12
12
  import { UseQueryLightError } from './UseQueryLightError';
13
13
  var transformError = function transformError(_ref) {
14
14
  var error = _ref.error,
@@ -1,2 +1,2 @@
1
- import { type TeamMembership } from '../../types';
1
+ import { type TeamMembership } from '../../types/membership';
2
2
  export declare function isInvited(member?: TeamMembership): member is TeamMembership & boolean;
@@ -1,2 +1,2 @@
1
- import { type TeamMembership } from '../../types';
1
+ import { type TeamMembership } from '../../types/membership';
2
2
  export declare const isMember: (member?: TeamMembership) => boolean;
@@ -1,2 +1,2 @@
1
- import { type TeamMembership } from '../../types';
1
+ import { type TeamMembership } from '../../types/membership';
2
2
  export declare const isNonMember: (member?: TeamMembership) => boolean;
@@ -1,2 +1,2 @@
1
- import { type TeamMembership } from '../../types';
1
+ import { type TeamMembership } from '../../types/membership';
2
2
  export declare const isRequestingJoin: (member?: TeamMembership) => boolean;
@@ -1,2 +1,2 @@
1
- import { type TeamMembership } from '../../types';
1
+ import { type TeamMembership } from '../../types/membership';
2
2
  export declare const sortMembersByType: (members: TeamMembership[], currentAccountId?: string) => TeamMembership[];
@@ -4,17 +4,25 @@ export { isTeamMembershipWithUser } from './types/membership';
4
4
  export { teamsClient, TeamsClient } from './services/main';
5
5
  export { useTeamsClientSetupNext } from './services/hooks/use-teams-client-setup-next';
6
6
  export { useTeamsClientSetup } from './services/hooks/use-teams-client-setup';
7
- export { AllTeamActions, hasPermission } from './common/utils/permissions';
8
- export type { TeamAction } from './common/utils/permissions';
7
+ export { AllTeamActions } from './common/utils/permissions/types';
8
+ export { hasPermission } from './common/utils/permissions/has-permission';
9
+ export type { TeamAction } from './common/utils/permissions/types';
9
10
  export { initialiseSentry } from './services/sentry/utils/initialise-sentry';
10
11
  export { logException } from './services/sentry/logException';
11
12
  export { logInfoMessage } from './services/sentry/logInfoMessage';
12
13
  export type { SentryClient } from './services/sentry/types';
13
14
  export { userInfoProvider, UserInfoProvider } from './services/user-info-provider/main';
14
- export { sortMembersByType, isInvited, isMember, isNonMember, isRequestingJoin, } from './common/utils';
15
+ export { sortMembersByType } from './common/utils/sort-teams';
16
+ export { isInvited } from './common/utils/is-invited';
17
+ export { isMember } from './common/utils/is-member';
18
+ export { isNonMember } from './common/utils/is-non-member';
19
+ export { isRequestingJoin } from './common/utils/is-requesting-join';
15
20
  export { toTeamARI } from './common/utils/to-team-ari';
16
21
  export { toTeamId } from './common/utils/to-team-id';
17
22
  export { toUserARI } from './common/utils/to-user-ari';
18
23
  export { toUserId } from './common/utils/to-user-id';
19
- export { useLazyQueryLight, useQueryLight, UseQueryLightError, type ActualGraphQLError, } from './services/use-query-light';
20
- export type { FetchMoreArgs, QueryOptions } from './services/use-query-light';
24
+ export { useLazyQueryLight } from './services/use-query-light/useLazyQueryLight';
25
+ export { useQueryLight } from './services/use-query-light/useQueryLight';
26
+ export { UseQueryLightError } from './services/use-query-light/UseQueryLightError';
27
+ export { type ActualGraphQLError } from './services/use-query-light/ActualGraphQLError';
28
+ export type { FetchMoreArgs, QueryOptions } from './services/use-query-light/types';
@@ -1,2 +1,2 @@
1
- import { type TeamMembership } from '../types';
1
+ import { type TeamMembership } from '../types/membership';
2
2
  export declare const fixedTeamMemberships: (n?: number) => TeamMembership[];
@@ -1,3 +1,3 @@
1
- import { type Team } from '../types';
1
+ import { type Team } from '../types/team';
2
2
  import type { MockConfig } from './mock-config';
3
3
  export declare function randomReturnedNewTeamData({ faker }: MockConfig, customProps?: Partial<Team>): Team;
@@ -1,3 +1,3 @@
1
- import { type TeamMembership } from '../types';
1
+ import { type TeamMembership } from '../types/membership';
2
2
  import type { MockConfig } from './mock-config';
3
3
  export declare const randomTeamMembership: ({ faker }: MockConfig, customProps?: {}) => TeamMembership;