@atlaskit/link-datasource 6.13.3 → 6.13.4
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.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/services/getAvailableSites.js +5 -3
- package/dist/cjs/services/isLinkDatasourceInUnitsRollout.js +25 -0
- package/dist/es2019/services/getAvailableSites.js +6 -2
- package/dist/es2019/services/isLinkDatasourceInUnitsRollout.js +20 -0
- package/dist/esm/services/getAvailableSites.js +5 -3
- package/dist/esm/services/isLinkDatasourceInUnitsRollout.js +20 -0
- package/dist/types/services/isLinkDatasourceInUnitsRollout.d.ts +14 -0
- package/package.json +2 -2
- package/dist/cjs/services/__clearUnitsRolloutSettingsCacheForTests.js +0 -13
- package/dist/cjs/services/getUnitsRolloutSettings.js +0 -199
- package/dist/cjs/services/isUnitsIsolationEnabled.js +0 -63
- package/dist/es2019/services/__clearUnitsRolloutSettingsCacheForTests.js +0 -8
- package/dist/es2019/services/getUnitsRolloutSettings.js +0 -112
- package/dist/es2019/services/isUnitsIsolationEnabled.js +0 -34
- package/dist/esm/services/__clearUnitsRolloutSettingsCacheForTests.js +0 -8
- package/dist/esm/services/getUnitsRolloutSettings.js +0 -192
- package/dist/esm/services/isUnitsIsolationEnabled.js +0 -57
- package/dist/types/services/__clearUnitsRolloutSettingsCacheForTests.d.ts +0 -4
- package/dist/types/services/getUnitsRolloutSettings.d.ts +0 -29
- package/dist/types/services/isUnitsIsolationEnabled.d.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/link-datasource
|
|
2
2
|
|
|
3
|
+
## 6.13.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2474922a7a598`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2474922a7a598) -
|
|
8
|
+
Internal change only. The units rollout check now uses the shared
|
|
9
|
+
`@atlaskit/linking-common/units-rollout` helper instead of a local copy. Behaviour is unchanged.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 6.13.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -8,7 +8,8 @@ exports.getAccessibleProducts = void 0;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _hooks = require("@atlaskit/linking-common/hooks");
|
|
11
|
-
var
|
|
11
|
+
var _unitsRollout = require("@atlaskit/linking-common/units-rollout");
|
|
12
|
+
var _isLinkDatasourceInUnitsRollout = require("./isLinkDatasourceInUnitsRollout");
|
|
12
13
|
var getAccessibleProducts = exports.getAccessibleProducts = /*#__PURE__*/function () {
|
|
13
14
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(product) {
|
|
14
15
|
var requestConfig, endpoint, response, res, _t, _t2, _t3, _t4;
|
|
@@ -26,9 +27,10 @@ var getAccessibleProducts = exports.getAccessibleProducts = /*#__PURE__*/functio
|
|
|
26
27
|
body: JSON.stringify({
|
|
27
28
|
productIds: product === 'confluence' ? ['confluence.ondemand'] : ['jira-software.ondemand', 'jira-core.ondemand', 'jira-incident-manager.ondemand', 'jira-product-discovery', 'jira-servicedesk.ondemand']
|
|
28
29
|
})
|
|
29
|
-
};
|
|
30
|
+
}; // Organisations with units isolation in effect must be served the unit compliant endpoint,
|
|
31
|
+
// which filters the products down to the unit the user belongs to.
|
|
30
32
|
_context.next = 1;
|
|
31
|
-
return (0,
|
|
33
|
+
return (0, _unitsRollout.shouldUseUnitCompliantApi)(_isLinkDatasourceInUnitsRollout.isLinkDatasourceInUnitsRollout);
|
|
32
34
|
case 1:
|
|
33
35
|
if (!_context.sent) {
|
|
34
36
|
_context.next = 2;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isLinkDatasourceInUnitsRollout = void 0;
|
|
7
|
+
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
8
|
+
/**
|
|
9
|
+
* Whether link datasource is in the units isolation rollout.
|
|
10
|
+
*
|
|
11
|
+
* Two gates drive the same rollout so it can be turned on for either an organisation or a single
|
|
12
|
+
* site: `..._unit_compliant` targets org id, `..._unit_compliant_cloud_id` targets cloud id.
|
|
13
|
+
* Either one being on opts link datasource in, and both are always evaluated so that exposure is
|
|
14
|
+
* recorded for the two of them.
|
|
15
|
+
*
|
|
16
|
+
* Being in the rollout is not on its own enough to change behaviour - the organisation also has to
|
|
17
|
+
* have launched units with boundary enforcement on. Pass this to `shouldUseUnitCompliantApi` from
|
|
18
|
+
* `@atlaskit/linking-common/units-rollout`, which owns that decision, rather than calling it
|
|
19
|
+
* directly.
|
|
20
|
+
*/
|
|
21
|
+
var isLinkDatasourceInUnitsRollout = exports.isLinkDatasourceInUnitsRollout = function isLinkDatasourceInUnitsRollout() {
|
|
22
|
+
var isOrgInRollout = (0, _fg.fg)('linking_platform_link_datasource_unit_compliant');
|
|
23
|
+
var isSiteInRollout = (0, _fg.fg)('linking_platform_link_datasource_unit_compliant_cloud_id');
|
|
24
|
+
return isOrgInRollout || isSiteInRollout;
|
|
25
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mapAccessibleProductsToAvailableSites } from '@atlaskit/linking-common/hooks';
|
|
2
|
-
import {
|
|
2
|
+
import { shouldUseUnitCompliantApi } from '@atlaskit/linking-common/units-rollout';
|
|
3
|
+
import { isLinkDatasourceInUnitsRollout } from './isLinkDatasourceInUnitsRollout';
|
|
3
4
|
export const getAccessibleProducts = async product => {
|
|
4
5
|
const requestConfig = {
|
|
5
6
|
method: 'POST',
|
|
@@ -13,7 +14,10 @@ export const getAccessibleProducts = async product => {
|
|
|
13
14
|
productIds: product === 'confluence' ? ['confluence.ondemand'] : ['jira-software.ondemand', 'jira-core.ondemand', 'jira-incident-manager.ondemand', 'jira-product-discovery', 'jira-servicedesk.ondemand']
|
|
14
15
|
})
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
+
|
|
18
|
+
// Organisations with units isolation in effect must be served the unit compliant endpoint,
|
|
19
|
+
// which filters the products down to the unit the user belongs to.
|
|
20
|
+
const endpoint = (await shouldUseUnitCompliantApi(isLinkDatasourceInUnitsRollout)) ? '/gateway/api/experimental/v2/accessible-products' : '/gateway/api/v2/accessible-products';
|
|
17
21
|
const response = await fetch(endpoint, requestConfig);
|
|
18
22
|
if (response.ok) {
|
|
19
23
|
const res = await response.json();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether link datasource is in the units isolation rollout.
|
|
5
|
+
*
|
|
6
|
+
* Two gates drive the same rollout so it can be turned on for either an organisation or a single
|
|
7
|
+
* site: `..._unit_compliant` targets org id, `..._unit_compliant_cloud_id` targets cloud id.
|
|
8
|
+
* Either one being on opts link datasource in, and both are always evaluated so that exposure is
|
|
9
|
+
* recorded for the two of them.
|
|
10
|
+
*
|
|
11
|
+
* Being in the rollout is not on its own enough to change behaviour - the organisation also has to
|
|
12
|
+
* have launched units with boundary enforcement on. Pass this to `shouldUseUnitCompliantApi` from
|
|
13
|
+
* `@atlaskit/linking-common/units-rollout`, which owns that decision, rather than calling it
|
|
14
|
+
* directly.
|
|
15
|
+
*/
|
|
16
|
+
export const isLinkDatasourceInUnitsRollout = () => {
|
|
17
|
+
const isOrgInRollout = fg('linking_platform_link_datasource_unit_compliant');
|
|
18
|
+
const isSiteInRollout = fg('linking_platform_link_datasource_unit_compliant_cloud_id');
|
|
19
|
+
return isOrgInRollout || isSiteInRollout;
|
|
20
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { mapAccessibleProductsToAvailableSites } from '@atlaskit/linking-common/hooks';
|
|
4
|
-
import {
|
|
4
|
+
import { shouldUseUnitCompliantApi } from '@atlaskit/linking-common/units-rollout';
|
|
5
|
+
import { isLinkDatasourceInUnitsRollout } from './isLinkDatasourceInUnitsRollout';
|
|
5
6
|
export var getAccessibleProducts = /*#__PURE__*/function () {
|
|
6
7
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(product) {
|
|
7
8
|
var requestConfig, endpoint, response, res, _t, _t2, _t3, _t4;
|
|
@@ -19,9 +20,10 @@ export var getAccessibleProducts = /*#__PURE__*/function () {
|
|
|
19
20
|
body: JSON.stringify({
|
|
20
21
|
productIds: product === 'confluence' ? ['confluence.ondemand'] : ['jira-software.ondemand', 'jira-core.ondemand', 'jira-incident-manager.ondemand', 'jira-product-discovery', 'jira-servicedesk.ondemand']
|
|
21
22
|
})
|
|
22
|
-
};
|
|
23
|
+
}; // Organisations with units isolation in effect must be served the unit compliant endpoint,
|
|
24
|
+
// which filters the products down to the unit the user belongs to.
|
|
23
25
|
_context.next = 1;
|
|
24
|
-
return
|
|
26
|
+
return shouldUseUnitCompliantApi(isLinkDatasourceInUnitsRollout);
|
|
25
27
|
case 1:
|
|
26
28
|
if (!_context.sent) {
|
|
27
29
|
_context.next = 2;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether link datasource is in the units isolation rollout.
|
|
5
|
+
*
|
|
6
|
+
* Two gates drive the same rollout so it can be turned on for either an organisation or a single
|
|
7
|
+
* site: `..._unit_compliant` targets org id, `..._unit_compliant_cloud_id` targets cloud id.
|
|
8
|
+
* Either one being on opts link datasource in, and both are always evaluated so that exposure is
|
|
9
|
+
* recorded for the two of them.
|
|
10
|
+
*
|
|
11
|
+
* Being in the rollout is not on its own enough to change behaviour - the organisation also has to
|
|
12
|
+
* have launched units with boundary enforcement on. Pass this to `shouldUseUnitCompliantApi` from
|
|
13
|
+
* `@atlaskit/linking-common/units-rollout`, which owns that decision, rather than calling it
|
|
14
|
+
* directly.
|
|
15
|
+
*/
|
|
16
|
+
export var isLinkDatasourceInUnitsRollout = function isLinkDatasourceInUnitsRollout() {
|
|
17
|
+
var isOrgInRollout = fg('linking_platform_link_datasource_unit_compliant');
|
|
18
|
+
var isSiteInRollout = fg('linking_platform_link_datasource_unit_compliant_cloud_id');
|
|
19
|
+
return isOrgInRollout || isSiteInRollout;
|
|
20
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether link datasource is in the units isolation rollout.
|
|
3
|
+
*
|
|
4
|
+
* Two gates drive the same rollout so it can be turned on for either an organisation or a single
|
|
5
|
+
* site: `..._unit_compliant` targets org id, `..._unit_compliant_cloud_id` targets cloud id.
|
|
6
|
+
* Either one being on opts link datasource in, and both are always evaluated so that exposure is
|
|
7
|
+
* recorded for the two of them.
|
|
8
|
+
*
|
|
9
|
+
* Being in the rollout is not on its own enough to change behaviour - the organisation also has to
|
|
10
|
+
* have launched units with boundary enforcement on. Pass this to `shouldUseUnitCompliantApi` from
|
|
11
|
+
* `@atlaskit/linking-common/units-rollout`, which owns that decision, rather than calling it
|
|
12
|
+
* directly.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isLinkDatasourceInUnitsRollout: () => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-datasource",
|
|
3
|
-
"version": "6.13.
|
|
3
|
+
"version": "6.13.4",
|
|
4
4
|
"description": "UI Components to support linking platform dataset feature",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@atlaskit/link": "^5.1.0",
|
|
65
65
|
"@atlaskit/link-client-extension": "^7.3.0",
|
|
66
66
|
"@atlaskit/link-provider": "^5.6.0",
|
|
67
|
-
"@atlaskit/linking-common": "^12.
|
|
67
|
+
"@atlaskit/linking-common": "^12.2.0",
|
|
68
68
|
"@atlaskit/linking-types": "^15.3.0",
|
|
69
69
|
"@atlaskit/logo": "^23.0.0",
|
|
70
70
|
"@atlaskit/lozenge": "^15.4.0",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.__clearUnitsRolloutSettingsCacheForTests = void 0;
|
|
7
|
-
var _getUnitsRolloutSettings = require("./getUnitsRolloutSettings");
|
|
8
|
-
/**
|
|
9
|
-
* Test-only: clear the cached units rollout settings so each test starts with a clean slate.
|
|
10
|
-
*/
|
|
11
|
-
var __clearUnitsRolloutSettingsCacheForTests = exports.__clearUnitsRolloutSettingsCacheForTests = function __clearUnitsRolloutSettingsCacheForTests() {
|
|
12
|
-
_getUnitsRolloutSettings.cache.promise = undefined;
|
|
13
|
-
};
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.unitsRolloutSettingsQuery = exports.tenantContextQuery = exports.getUnitsRolloutSettings = exports.cache = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _linkingCommon = require("@atlaskit/linking-common");
|
|
11
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
12
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
-
var AGG_URL = '/gateway/api/graphql';
|
|
15
|
-
var TENANT_CONTEXT_OPERATION_NAME = 'link_datasource_tenantContext';
|
|
16
|
-
var UNITS_ROLLOUT_SETTINGS_OPERATION_NAME = 'link_datasource_unitSettings';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* `Query.admin_unitSettings` is keyed by org id, which the browser does not know, so the org id
|
|
20
|
-
* is resolved from the host the product is currently served from.
|
|
21
|
-
*/
|
|
22
|
-
var tenantContextQuery = exports.tenantContextQuery = "\n\tquery ".concat(TENANT_CONTEXT_OPERATION_NAME, "($hostNames: [String!]) {\n\t\ttenantContexts(hostNames: $hostNames) {\n\t\t\torgId\n\t\t}\n\t}\n");
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* `admin_unitSettings` exposes both flags of the rollout and is callable with the session of the
|
|
26
|
-
* end user, so no opt-in directive or admin OAuth scope is needed from the browser.
|
|
27
|
-
*/
|
|
28
|
-
var unitsRolloutSettingsQuery = exports.unitsRolloutSettingsQuery = "\n\tquery ".concat(UNITS_ROLLOUT_SETTINGS_OPERATION_NAME, "($orgId: ID!) {\n\t\tadmin_unitSettings(orgId: $orgId) {\n\t\t\tboundaryEnforced\n\t\t\tendUsersLaunched\n\t\t}\n\t}\n");
|
|
29
|
-
/**
|
|
30
|
-
* When the rollout settings cannot be resolved we keep the pre-isolation behaviour, which is
|
|
31
|
-
* what every org gets today while the unit settings are unset. The settings are only
|
|
32
|
-
* written when an org is activated - they are not backfilled - so `null` is expected for orgs
|
|
33
|
-
* that have not been activated yet and must be read as `false`.
|
|
34
|
-
*/
|
|
35
|
-
var DEFAULT_SETTINGS = {
|
|
36
|
-
boundaryEnforced: false,
|
|
37
|
-
endUsersLaunched: false
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Holds the in-flight/resolved request so that the settings are only fetched once per page load.
|
|
42
|
-
*/
|
|
43
|
-
var cache = exports.cache = {};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* AGG answers with a 200 and an `errors` array for query level failures, so those have to be
|
|
47
|
-
* turned into a rejection explicitly rather than being read as an empty response.
|
|
48
|
-
*/
|
|
49
|
-
var requestGraphQL = /*#__PURE__*/function () {
|
|
50
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(operationName, query, variables) {
|
|
51
|
-
var _response$errors, _response$data;
|
|
52
|
-
var response, messages;
|
|
53
|
-
return _regenerator.default.wrap(function (_context) {
|
|
54
|
-
while (1) switch (_context.prev = _context.next) {
|
|
55
|
-
case 0:
|
|
56
|
-
_context.next = 1;
|
|
57
|
-
return (0, _linkingCommon.request)('post', AGG_URL, {
|
|
58
|
-
operationName: operationName,
|
|
59
|
-
query: query,
|
|
60
|
-
variables: variables
|
|
61
|
-
});
|
|
62
|
-
case 1:
|
|
63
|
-
response = _context.sent;
|
|
64
|
-
if (!(response !== null && response !== void 0 && (_response$errors = response.errors) !== null && _response$errors !== void 0 && _response$errors.length)) {
|
|
65
|
-
_context.next = 2;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
messages = response.errors.map(function (error) {
|
|
69
|
-
return error === null || error === void 0 ? void 0 : error.message;
|
|
70
|
-
}).filter(Boolean).join(', ');
|
|
71
|
-
throw new Error("".concat(operationName, " failed: ").concat(messages || 'unknown error'));
|
|
72
|
-
case 2:
|
|
73
|
-
return _context.abrupt("return", (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : undefined);
|
|
74
|
-
case 3:
|
|
75
|
-
case "end":
|
|
76
|
-
return _context.stop();
|
|
77
|
-
}
|
|
78
|
-
}, _callee);
|
|
79
|
-
}));
|
|
80
|
-
return function requestGraphQL(_x, _x2, _x3) {
|
|
81
|
-
return _ref.apply(this, arguments);
|
|
82
|
-
};
|
|
83
|
-
}();
|
|
84
|
-
var fetchOrgId = /*#__PURE__*/function () {
|
|
85
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
86
|
-
var _window$location, _data$tenantContexts;
|
|
87
|
-
var hostName, data, _iterator, _step, tenantContext, _t;
|
|
88
|
-
return _regenerator.default.wrap(function (_context2) {
|
|
89
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
90
|
-
case 0:
|
|
91
|
-
hostName = typeof window !== 'undefined' ? (_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname : undefined;
|
|
92
|
-
if (hostName) {
|
|
93
|
-
_context2.next = 1;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
return _context2.abrupt("return", undefined);
|
|
97
|
-
case 1:
|
|
98
|
-
_context2.next = 2;
|
|
99
|
-
return requestGraphQL(TENANT_CONTEXT_OPERATION_NAME, tenantContextQuery, {
|
|
100
|
-
hostNames: [hostName]
|
|
101
|
-
});
|
|
102
|
-
case 2:
|
|
103
|
-
data = _context2.sent;
|
|
104
|
-
_iterator = _createForOfIteratorHelper((_data$tenantContexts = data === null || data === void 0 ? void 0 : data.tenantContexts) !== null && _data$tenantContexts !== void 0 ? _data$tenantContexts : []);
|
|
105
|
-
_context2.prev = 3;
|
|
106
|
-
_iterator.s();
|
|
107
|
-
case 4:
|
|
108
|
-
if ((_step = _iterator.n()).done) {
|
|
109
|
-
_context2.next = 6;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
tenantContext = _step.value;
|
|
113
|
-
if (!(tenantContext !== null && tenantContext !== void 0 && tenantContext.orgId)) {
|
|
114
|
-
_context2.next = 5;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
return _context2.abrupt("return", tenantContext.orgId);
|
|
118
|
-
case 5:
|
|
119
|
-
_context2.next = 4;
|
|
120
|
-
break;
|
|
121
|
-
case 6:
|
|
122
|
-
_context2.next = 8;
|
|
123
|
-
break;
|
|
124
|
-
case 7:
|
|
125
|
-
_context2.prev = 7;
|
|
126
|
-
_t = _context2["catch"](3);
|
|
127
|
-
_iterator.e(_t);
|
|
128
|
-
case 8:
|
|
129
|
-
_context2.prev = 8;
|
|
130
|
-
_iterator.f();
|
|
131
|
-
return _context2.finish(8);
|
|
132
|
-
case 9:
|
|
133
|
-
return _context2.abrupt("return", undefined);
|
|
134
|
-
case 10:
|
|
135
|
-
case "end":
|
|
136
|
-
return _context2.stop();
|
|
137
|
-
}
|
|
138
|
-
}, _callee2, null, [[3, 7, 8, 9]]);
|
|
139
|
-
}));
|
|
140
|
-
return function fetchOrgId() {
|
|
141
|
-
return _ref2.apply(this, arguments);
|
|
142
|
-
};
|
|
143
|
-
}();
|
|
144
|
-
var fetchUnitsRolloutSettings = /*#__PURE__*/function () {
|
|
145
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
146
|
-
var _settings$boundaryEnf, _settings$endUsersLau;
|
|
147
|
-
var orgId, data, settings;
|
|
148
|
-
return _regenerator.default.wrap(function (_context3) {
|
|
149
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
150
|
-
case 0:
|
|
151
|
-
_context3.next = 1;
|
|
152
|
-
return fetchOrgId();
|
|
153
|
-
case 1:
|
|
154
|
-
orgId = _context3.sent;
|
|
155
|
-
if (orgId) {
|
|
156
|
-
_context3.next = 2;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
return _context3.abrupt("return", DEFAULT_SETTINGS);
|
|
160
|
-
case 2:
|
|
161
|
-
_context3.next = 3;
|
|
162
|
-
return requestGraphQL(UNITS_ROLLOUT_SETTINGS_OPERATION_NAME, unitsRolloutSettingsQuery, {
|
|
163
|
-
orgId: orgId
|
|
164
|
-
});
|
|
165
|
-
case 3:
|
|
166
|
-
data = _context3.sent;
|
|
167
|
-
settings = data === null || data === void 0 ? void 0 : data.admin_unitSettings;
|
|
168
|
-
return _context3.abrupt("return", {
|
|
169
|
-
boundaryEnforced: (_settings$boundaryEnf = settings === null || settings === void 0 ? void 0 : settings.boundaryEnforced) !== null && _settings$boundaryEnf !== void 0 ? _settings$boundaryEnf : false,
|
|
170
|
-
endUsersLaunched: (_settings$endUsersLau = settings === null || settings === void 0 ? void 0 : settings.endUsersLaunched) !== null && _settings$endUsersLau !== void 0 ? _settings$endUsersLau : false
|
|
171
|
-
});
|
|
172
|
-
case 4:
|
|
173
|
-
case "end":
|
|
174
|
-
return _context3.stop();
|
|
175
|
-
}
|
|
176
|
-
}, _callee3);
|
|
177
|
-
}));
|
|
178
|
-
return function fetchUnitsRolloutSettings() {
|
|
179
|
-
return _ref3.apply(this, arguments);
|
|
180
|
-
};
|
|
181
|
-
}();
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Reads the org's units rollout settings (`boundaryEnforced` and `endUsersLaunched`) from the
|
|
185
|
-
* TCS key exposed by AGG's `Query.admin_unitSettings`.
|
|
186
|
-
*
|
|
187
|
-
* The result is cached for the lifetime of the page because the settings only change when an
|
|
188
|
-
* admin activates or launches units, which requires a reload to be picked up anyway. A failed
|
|
189
|
-
* request is not cached so that a later call can retry.
|
|
190
|
-
*/
|
|
191
|
-
var getUnitsRolloutSettings = exports.getUnitsRolloutSettings = function getUnitsRolloutSettings() {
|
|
192
|
-
if (!cache.promise) {
|
|
193
|
-
cache.promise = fetchUnitsRolloutSettings().catch(function () {
|
|
194
|
-
cache.promise = undefined;
|
|
195
|
-
return DEFAULT_SETTINGS;
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
return cache.promise;
|
|
199
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.isUnitsIsolationEnabled = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
11
|
-
var _getUnitsRolloutSettings = require("./getUnitsRolloutSettings");
|
|
12
|
-
/**
|
|
13
|
-
* Whether unit isolation behaviour should be applied for the current org.
|
|
14
|
-
*
|
|
15
|
-
* An org is isolated when units GA is on, the org has been opted in to the rollout - either by
|
|
16
|
-
* org id or by cloud id - *and* the org has actually launched units with boundary enforcement
|
|
17
|
-
* turned on:
|
|
18
|
-
*
|
|
19
|
-
* `cc-units-ga on -> (orgId gate on || cloudId gate on) -> endUsersLaunched && boundaryEnforced -> isolate`
|
|
20
|
-
*
|
|
21
|
-
* `cc-units-ga` is the units GA master gate and acts as the killswitch: while it is off nothing
|
|
22
|
-
* else is evaluated and the current, non-isolated behaviour is kept. The AGG call is only made
|
|
23
|
-
* when one of the rollout gates passes, so orgs outside of the rollout do not pay for an extra
|
|
24
|
-
* request.
|
|
25
|
-
*/
|
|
26
|
-
var isUnitsIsolationEnabled = exports.isUnitsIsolationEnabled = /*#__PURE__*/function () {
|
|
27
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
28
|
-
var isOrgInRollout, isCloudInRollout, _yield$getUnitsRollou, boundaryEnforced, endUsersLaunched;
|
|
29
|
-
return _regenerator.default.wrap(function (_context) {
|
|
30
|
-
while (1) switch (_context.prev = _context.next) {
|
|
31
|
-
case 0:
|
|
32
|
-
if ((0, _fg.fg)('cc-units-ga')) {
|
|
33
|
-
_context.next = 1;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
return _context.abrupt("return", false);
|
|
37
|
-
case 1:
|
|
38
|
-
// Both rollout gates are always evaluated so that exposure is recorded consistently.
|
|
39
|
-
isOrgInRollout = (0, _fg.fg)('linking_platform_link_datasource_unit_compliant');
|
|
40
|
-
isCloudInRollout = (0, _fg.fg)('linking_platform_link_datasource_unit_compliant_cloud_id');
|
|
41
|
-
if (!(!isOrgInRollout && !isCloudInRollout)) {
|
|
42
|
-
_context.next = 2;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
return _context.abrupt("return", false);
|
|
46
|
-
case 2:
|
|
47
|
-
_context.next = 3;
|
|
48
|
-
return (0, _getUnitsRolloutSettings.getUnitsRolloutSettings)();
|
|
49
|
-
case 3:
|
|
50
|
-
_yield$getUnitsRollou = _context.sent;
|
|
51
|
-
boundaryEnforced = _yield$getUnitsRollou.boundaryEnforced;
|
|
52
|
-
endUsersLaunched = _yield$getUnitsRollou.endUsersLaunched;
|
|
53
|
-
return _context.abrupt("return", boundaryEnforced && endUsersLaunched);
|
|
54
|
-
case 4:
|
|
55
|
-
case "end":
|
|
56
|
-
return _context.stop();
|
|
57
|
-
}
|
|
58
|
-
}, _callee);
|
|
59
|
-
}));
|
|
60
|
-
return function isUnitsIsolationEnabled() {
|
|
61
|
-
return _ref.apply(this, arguments);
|
|
62
|
-
};
|
|
63
|
-
}();
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { request } from '@atlaskit/linking-common';
|
|
2
|
-
const AGG_URL = '/gateway/api/graphql';
|
|
3
|
-
const TENANT_CONTEXT_OPERATION_NAME = 'link_datasource_tenantContext';
|
|
4
|
-
const UNITS_ROLLOUT_SETTINGS_OPERATION_NAME = 'link_datasource_unitSettings';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* `Query.admin_unitSettings` is keyed by org id, which the browser does not know, so the org id
|
|
8
|
-
* is resolved from the host the product is currently served from.
|
|
9
|
-
*/
|
|
10
|
-
export const tenantContextQuery = `
|
|
11
|
-
query ${TENANT_CONTEXT_OPERATION_NAME}($hostNames: [String!]) {
|
|
12
|
-
tenantContexts(hostNames: $hostNames) {
|
|
13
|
-
orgId
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* `admin_unitSettings` exposes both flags of the rollout and is callable with the session of the
|
|
20
|
-
* end user, so no opt-in directive or admin OAuth scope is needed from the browser.
|
|
21
|
-
*/
|
|
22
|
-
export const unitsRolloutSettingsQuery = `
|
|
23
|
-
query ${UNITS_ROLLOUT_SETTINGS_OPERATION_NAME}($orgId: ID!) {
|
|
24
|
-
admin_unitSettings(orgId: $orgId) {
|
|
25
|
-
boundaryEnforced
|
|
26
|
-
endUsersLaunched
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
/**
|
|
31
|
-
* When the rollout settings cannot be resolved we keep the pre-isolation behaviour, which is
|
|
32
|
-
* what every org gets today while the unit settings are unset. The settings are only
|
|
33
|
-
* written when an org is activated - they are not backfilled - so `null` is expected for orgs
|
|
34
|
-
* that have not been activated yet and must be read as `false`.
|
|
35
|
-
*/
|
|
36
|
-
const DEFAULT_SETTINGS = {
|
|
37
|
-
boundaryEnforced: false,
|
|
38
|
-
endUsersLaunched: false
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Holds the in-flight/resolved request so that the settings are only fetched once per page load.
|
|
43
|
-
*/
|
|
44
|
-
export const cache = {};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* AGG answers with a 200 and an `errors` array for query level failures, so those have to be
|
|
48
|
-
* turned into a rejection explicitly rather than being read as an empty response.
|
|
49
|
-
*/
|
|
50
|
-
const requestGraphQL = async (operationName, query, variables) => {
|
|
51
|
-
var _response$errors, _response$data;
|
|
52
|
-
const response = await request('post', AGG_URL, {
|
|
53
|
-
operationName,
|
|
54
|
-
query,
|
|
55
|
-
variables
|
|
56
|
-
});
|
|
57
|
-
if (response !== null && response !== void 0 && (_response$errors = response.errors) !== null && _response$errors !== void 0 && _response$errors.length) {
|
|
58
|
-
const messages = response.errors.map(error => error === null || error === void 0 ? void 0 : error.message).filter(Boolean).join(', ');
|
|
59
|
-
throw new Error(`${operationName} failed: ${messages || 'unknown error'}`);
|
|
60
|
-
}
|
|
61
|
-
return (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : undefined;
|
|
62
|
-
};
|
|
63
|
-
const fetchOrgId = async () => {
|
|
64
|
-
var _window$location;
|
|
65
|
-
const hostName = typeof window !== 'undefined' ? (_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname : undefined;
|
|
66
|
-
if (!hostName) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
const data = await requestGraphQL(TENANT_CONTEXT_OPERATION_NAME, tenantContextQuery, {
|
|
70
|
-
hostNames: [hostName]
|
|
71
|
-
});
|
|
72
|
-
for (const tenantContext of (_data$tenantContexts = data === null || data === void 0 ? void 0 : data.tenantContexts) !== null && _data$tenantContexts !== void 0 ? _data$tenantContexts : []) {
|
|
73
|
-
var _data$tenantContexts;
|
|
74
|
-
if (tenantContext !== null && tenantContext !== void 0 && tenantContext.orgId) {
|
|
75
|
-
return tenantContext.orgId;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
79
|
-
};
|
|
80
|
-
const fetchUnitsRolloutSettings = async () => {
|
|
81
|
-
var _settings$boundaryEnf, _settings$endUsersLau;
|
|
82
|
-
const orgId = await fetchOrgId();
|
|
83
|
-
if (!orgId) {
|
|
84
|
-
return DEFAULT_SETTINGS;
|
|
85
|
-
}
|
|
86
|
-
const data = await requestGraphQL(UNITS_ROLLOUT_SETTINGS_OPERATION_NAME, unitsRolloutSettingsQuery, {
|
|
87
|
-
orgId
|
|
88
|
-
});
|
|
89
|
-
const settings = data === null || data === void 0 ? void 0 : data.admin_unitSettings;
|
|
90
|
-
return {
|
|
91
|
-
boundaryEnforced: (_settings$boundaryEnf = settings === null || settings === void 0 ? void 0 : settings.boundaryEnforced) !== null && _settings$boundaryEnf !== void 0 ? _settings$boundaryEnf : false,
|
|
92
|
-
endUsersLaunched: (_settings$endUsersLau = settings === null || settings === void 0 ? void 0 : settings.endUsersLaunched) !== null && _settings$endUsersLau !== void 0 ? _settings$endUsersLau : false
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Reads the org's units rollout settings (`boundaryEnforced` and `endUsersLaunched`) from the
|
|
98
|
-
* TCS key exposed by AGG's `Query.admin_unitSettings`.
|
|
99
|
-
*
|
|
100
|
-
* The result is cached for the lifetime of the page because the settings only change when an
|
|
101
|
-
* admin activates or launches units, which requires a reload to be picked up anyway. A failed
|
|
102
|
-
* request is not cached so that a later call can retry.
|
|
103
|
-
*/
|
|
104
|
-
export const getUnitsRolloutSettings = () => {
|
|
105
|
-
if (!cache.promise) {
|
|
106
|
-
cache.promise = fetchUnitsRolloutSettings().catch(() => {
|
|
107
|
-
cache.promise = undefined;
|
|
108
|
-
return DEFAULT_SETTINGS;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return cache.promise;
|
|
112
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
2
|
-
import { getUnitsRolloutSettings } from './getUnitsRolloutSettings';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Whether unit isolation behaviour should be applied for the current org.
|
|
6
|
-
*
|
|
7
|
-
* An org is isolated when units GA is on, the org has been opted in to the rollout - either by
|
|
8
|
-
* org id or by cloud id - *and* the org has actually launched units with boundary enforcement
|
|
9
|
-
* turned on:
|
|
10
|
-
*
|
|
11
|
-
* `cc-units-ga on -> (orgId gate on || cloudId gate on) -> endUsersLaunched && boundaryEnforced -> isolate`
|
|
12
|
-
*
|
|
13
|
-
* `cc-units-ga` is the units GA master gate and acts as the killswitch: while it is off nothing
|
|
14
|
-
* else is evaluated and the current, non-isolated behaviour is kept. The AGG call is only made
|
|
15
|
-
* when one of the rollout gates passes, so orgs outside of the rollout do not pay for an extra
|
|
16
|
-
* request.
|
|
17
|
-
*/
|
|
18
|
-
export const isUnitsIsolationEnabled = async () => {
|
|
19
|
-
if (!fg('cc-units-ga')) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Both rollout gates are always evaluated so that exposure is recorded consistently.
|
|
24
|
-
const isOrgInRollout = fg('linking_platform_link_datasource_unit_compliant');
|
|
25
|
-
const isCloudInRollout = fg('linking_platform_link_datasource_unit_compliant_cloud_id');
|
|
26
|
-
if (!isOrgInRollout && !isCloudInRollout) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
const {
|
|
30
|
-
boundaryEnforced,
|
|
31
|
-
endUsersLaunched
|
|
32
|
-
} = await getUnitsRolloutSettings();
|
|
33
|
-
return boundaryEnforced && endUsersLaunched;
|
|
34
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { cache } from './getUnitsRolloutSettings';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Test-only: clear the cached units rollout settings so each test starts with a clean slate.
|
|
5
|
-
*/
|
|
6
|
-
export var __clearUnitsRolloutSettingsCacheForTests = function __clearUnitsRolloutSettingsCacheForTests() {
|
|
7
|
-
cache.promise = undefined;
|
|
8
|
-
};
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
3
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
-
import { request } from '@atlaskit/linking-common';
|
|
7
|
-
var AGG_URL = '/gateway/api/graphql';
|
|
8
|
-
var TENANT_CONTEXT_OPERATION_NAME = 'link_datasource_tenantContext';
|
|
9
|
-
var UNITS_ROLLOUT_SETTINGS_OPERATION_NAME = 'link_datasource_unitSettings';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* `Query.admin_unitSettings` is keyed by org id, which the browser does not know, so the org id
|
|
13
|
-
* is resolved from the host the product is currently served from.
|
|
14
|
-
*/
|
|
15
|
-
export var tenantContextQuery = "\n\tquery ".concat(TENANT_CONTEXT_OPERATION_NAME, "($hostNames: [String!]) {\n\t\ttenantContexts(hostNames: $hostNames) {\n\t\t\torgId\n\t\t}\n\t}\n");
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* `admin_unitSettings` exposes both flags of the rollout and is callable with the session of the
|
|
19
|
-
* end user, so no opt-in directive or admin OAuth scope is needed from the browser.
|
|
20
|
-
*/
|
|
21
|
-
export var unitsRolloutSettingsQuery = "\n\tquery ".concat(UNITS_ROLLOUT_SETTINGS_OPERATION_NAME, "($orgId: ID!) {\n\t\tadmin_unitSettings(orgId: $orgId) {\n\t\t\tboundaryEnforced\n\t\t\tendUsersLaunched\n\t\t}\n\t}\n");
|
|
22
|
-
/**
|
|
23
|
-
* When the rollout settings cannot be resolved we keep the pre-isolation behaviour, which is
|
|
24
|
-
* what every org gets today while the unit settings are unset. The settings are only
|
|
25
|
-
* written when an org is activated - they are not backfilled - so `null` is expected for orgs
|
|
26
|
-
* that have not been activated yet and must be read as `false`.
|
|
27
|
-
*/
|
|
28
|
-
var DEFAULT_SETTINGS = {
|
|
29
|
-
boundaryEnforced: false,
|
|
30
|
-
endUsersLaunched: false
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Holds the in-flight/resolved request so that the settings are only fetched once per page load.
|
|
35
|
-
*/
|
|
36
|
-
export var cache = {};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* AGG answers with a 200 and an `errors` array for query level failures, so those have to be
|
|
40
|
-
* turned into a rejection explicitly rather than being read as an empty response.
|
|
41
|
-
*/
|
|
42
|
-
var requestGraphQL = /*#__PURE__*/function () {
|
|
43
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(operationName, query, variables) {
|
|
44
|
-
var _response$errors, _response$data;
|
|
45
|
-
var response, messages;
|
|
46
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
47
|
-
while (1) switch (_context.prev = _context.next) {
|
|
48
|
-
case 0:
|
|
49
|
-
_context.next = 1;
|
|
50
|
-
return request('post', AGG_URL, {
|
|
51
|
-
operationName: operationName,
|
|
52
|
-
query: query,
|
|
53
|
-
variables: variables
|
|
54
|
-
});
|
|
55
|
-
case 1:
|
|
56
|
-
response = _context.sent;
|
|
57
|
-
if (!(response !== null && response !== void 0 && (_response$errors = response.errors) !== null && _response$errors !== void 0 && _response$errors.length)) {
|
|
58
|
-
_context.next = 2;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
messages = response.errors.map(function (error) {
|
|
62
|
-
return error === null || error === void 0 ? void 0 : error.message;
|
|
63
|
-
}).filter(Boolean).join(', ');
|
|
64
|
-
throw new Error("".concat(operationName, " failed: ").concat(messages || 'unknown error'));
|
|
65
|
-
case 2:
|
|
66
|
-
return _context.abrupt("return", (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : undefined);
|
|
67
|
-
case 3:
|
|
68
|
-
case "end":
|
|
69
|
-
return _context.stop();
|
|
70
|
-
}
|
|
71
|
-
}, _callee);
|
|
72
|
-
}));
|
|
73
|
-
return function requestGraphQL(_x, _x2, _x3) {
|
|
74
|
-
return _ref.apply(this, arguments);
|
|
75
|
-
};
|
|
76
|
-
}();
|
|
77
|
-
var fetchOrgId = /*#__PURE__*/function () {
|
|
78
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
79
|
-
var _window$location, _data$tenantContexts;
|
|
80
|
-
var hostName, data, _iterator, _step, tenantContext, _t;
|
|
81
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
82
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
83
|
-
case 0:
|
|
84
|
-
hostName = typeof window !== 'undefined' ? (_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname : undefined;
|
|
85
|
-
if (hostName) {
|
|
86
|
-
_context2.next = 1;
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
return _context2.abrupt("return", undefined);
|
|
90
|
-
case 1:
|
|
91
|
-
_context2.next = 2;
|
|
92
|
-
return requestGraphQL(TENANT_CONTEXT_OPERATION_NAME, tenantContextQuery, {
|
|
93
|
-
hostNames: [hostName]
|
|
94
|
-
});
|
|
95
|
-
case 2:
|
|
96
|
-
data = _context2.sent;
|
|
97
|
-
_iterator = _createForOfIteratorHelper((_data$tenantContexts = data === null || data === void 0 ? void 0 : data.tenantContexts) !== null && _data$tenantContexts !== void 0 ? _data$tenantContexts : []);
|
|
98
|
-
_context2.prev = 3;
|
|
99
|
-
_iterator.s();
|
|
100
|
-
case 4:
|
|
101
|
-
if ((_step = _iterator.n()).done) {
|
|
102
|
-
_context2.next = 6;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
tenantContext = _step.value;
|
|
106
|
-
if (!(tenantContext !== null && tenantContext !== void 0 && tenantContext.orgId)) {
|
|
107
|
-
_context2.next = 5;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
return _context2.abrupt("return", tenantContext.orgId);
|
|
111
|
-
case 5:
|
|
112
|
-
_context2.next = 4;
|
|
113
|
-
break;
|
|
114
|
-
case 6:
|
|
115
|
-
_context2.next = 8;
|
|
116
|
-
break;
|
|
117
|
-
case 7:
|
|
118
|
-
_context2.prev = 7;
|
|
119
|
-
_t = _context2["catch"](3);
|
|
120
|
-
_iterator.e(_t);
|
|
121
|
-
case 8:
|
|
122
|
-
_context2.prev = 8;
|
|
123
|
-
_iterator.f();
|
|
124
|
-
return _context2.finish(8);
|
|
125
|
-
case 9:
|
|
126
|
-
return _context2.abrupt("return", undefined);
|
|
127
|
-
case 10:
|
|
128
|
-
case "end":
|
|
129
|
-
return _context2.stop();
|
|
130
|
-
}
|
|
131
|
-
}, _callee2, null, [[3, 7, 8, 9]]);
|
|
132
|
-
}));
|
|
133
|
-
return function fetchOrgId() {
|
|
134
|
-
return _ref2.apply(this, arguments);
|
|
135
|
-
};
|
|
136
|
-
}();
|
|
137
|
-
var fetchUnitsRolloutSettings = /*#__PURE__*/function () {
|
|
138
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
139
|
-
var _settings$boundaryEnf, _settings$endUsersLau;
|
|
140
|
-
var orgId, data, settings;
|
|
141
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
142
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
143
|
-
case 0:
|
|
144
|
-
_context3.next = 1;
|
|
145
|
-
return fetchOrgId();
|
|
146
|
-
case 1:
|
|
147
|
-
orgId = _context3.sent;
|
|
148
|
-
if (orgId) {
|
|
149
|
-
_context3.next = 2;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
return _context3.abrupt("return", DEFAULT_SETTINGS);
|
|
153
|
-
case 2:
|
|
154
|
-
_context3.next = 3;
|
|
155
|
-
return requestGraphQL(UNITS_ROLLOUT_SETTINGS_OPERATION_NAME, unitsRolloutSettingsQuery, {
|
|
156
|
-
orgId: orgId
|
|
157
|
-
});
|
|
158
|
-
case 3:
|
|
159
|
-
data = _context3.sent;
|
|
160
|
-
settings = data === null || data === void 0 ? void 0 : data.admin_unitSettings;
|
|
161
|
-
return _context3.abrupt("return", {
|
|
162
|
-
boundaryEnforced: (_settings$boundaryEnf = settings === null || settings === void 0 ? void 0 : settings.boundaryEnforced) !== null && _settings$boundaryEnf !== void 0 ? _settings$boundaryEnf : false,
|
|
163
|
-
endUsersLaunched: (_settings$endUsersLau = settings === null || settings === void 0 ? void 0 : settings.endUsersLaunched) !== null && _settings$endUsersLau !== void 0 ? _settings$endUsersLau : false
|
|
164
|
-
});
|
|
165
|
-
case 4:
|
|
166
|
-
case "end":
|
|
167
|
-
return _context3.stop();
|
|
168
|
-
}
|
|
169
|
-
}, _callee3);
|
|
170
|
-
}));
|
|
171
|
-
return function fetchUnitsRolloutSettings() {
|
|
172
|
-
return _ref3.apply(this, arguments);
|
|
173
|
-
};
|
|
174
|
-
}();
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Reads the org's units rollout settings (`boundaryEnforced` and `endUsersLaunched`) from the
|
|
178
|
-
* TCS key exposed by AGG's `Query.admin_unitSettings`.
|
|
179
|
-
*
|
|
180
|
-
* The result is cached for the lifetime of the page because the settings only change when an
|
|
181
|
-
* admin activates or launches units, which requires a reload to be picked up anyway. A failed
|
|
182
|
-
* request is not cached so that a later call can retry.
|
|
183
|
-
*/
|
|
184
|
-
export var getUnitsRolloutSettings = function getUnitsRolloutSettings() {
|
|
185
|
-
if (!cache.promise) {
|
|
186
|
-
cache.promise = fetchUnitsRolloutSettings().catch(function () {
|
|
187
|
-
cache.promise = undefined;
|
|
188
|
-
return DEFAULT_SETTINGS;
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
return cache.promise;
|
|
192
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
4
|
-
import { getUnitsRolloutSettings } from './getUnitsRolloutSettings';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Whether unit isolation behaviour should be applied for the current org.
|
|
8
|
-
*
|
|
9
|
-
* An org is isolated when units GA is on, the org has been opted in to the rollout - either by
|
|
10
|
-
* org id or by cloud id - *and* the org has actually launched units with boundary enforcement
|
|
11
|
-
* turned on:
|
|
12
|
-
*
|
|
13
|
-
* `cc-units-ga on -> (orgId gate on || cloudId gate on) -> endUsersLaunched && boundaryEnforced -> isolate`
|
|
14
|
-
*
|
|
15
|
-
* `cc-units-ga` is the units GA master gate and acts as the killswitch: while it is off nothing
|
|
16
|
-
* else is evaluated and the current, non-isolated behaviour is kept. The AGG call is only made
|
|
17
|
-
* when one of the rollout gates passes, so orgs outside of the rollout do not pay for an extra
|
|
18
|
-
* request.
|
|
19
|
-
*/
|
|
20
|
-
export var isUnitsIsolationEnabled = /*#__PURE__*/function () {
|
|
21
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
22
|
-
var isOrgInRollout, isCloudInRollout, _yield$getUnitsRollou, boundaryEnforced, endUsersLaunched;
|
|
23
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
24
|
-
while (1) switch (_context.prev = _context.next) {
|
|
25
|
-
case 0:
|
|
26
|
-
if (fg('cc-units-ga')) {
|
|
27
|
-
_context.next = 1;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
return _context.abrupt("return", false);
|
|
31
|
-
case 1:
|
|
32
|
-
// Both rollout gates are always evaluated so that exposure is recorded consistently.
|
|
33
|
-
isOrgInRollout = fg('linking_platform_link_datasource_unit_compliant');
|
|
34
|
-
isCloudInRollout = fg('linking_platform_link_datasource_unit_compliant_cloud_id');
|
|
35
|
-
if (!(!isOrgInRollout && !isCloudInRollout)) {
|
|
36
|
-
_context.next = 2;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
return _context.abrupt("return", false);
|
|
40
|
-
case 2:
|
|
41
|
-
_context.next = 3;
|
|
42
|
-
return getUnitsRolloutSettings();
|
|
43
|
-
case 3:
|
|
44
|
-
_yield$getUnitsRollou = _context.sent;
|
|
45
|
-
boundaryEnforced = _yield$getUnitsRollou.boundaryEnforced;
|
|
46
|
-
endUsersLaunched = _yield$getUnitsRollou.endUsersLaunched;
|
|
47
|
-
return _context.abrupt("return", boundaryEnforced && endUsersLaunched);
|
|
48
|
-
case 4:
|
|
49
|
-
case "end":
|
|
50
|
-
return _context.stop();
|
|
51
|
-
}
|
|
52
|
-
}, _callee);
|
|
53
|
-
}));
|
|
54
|
-
return function isUnitsIsolationEnabled() {
|
|
55
|
-
return _ref.apply(this, arguments);
|
|
56
|
-
};
|
|
57
|
-
}();
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `Query.admin_unitSettings` is keyed by org id, which the browser does not know, so the org id
|
|
3
|
-
* is resolved from the host the product is currently served from.
|
|
4
|
-
*/
|
|
5
|
-
export declare const tenantContextQuery: string;
|
|
6
|
-
/**
|
|
7
|
-
* `admin_unitSettings` exposes both flags of the rollout and is callable with the session of the
|
|
8
|
-
* end user, so no opt-in directive or admin OAuth scope is needed from the browser.
|
|
9
|
-
*/
|
|
10
|
-
export declare const unitsRolloutSettingsQuery: string;
|
|
11
|
-
export interface UnitsRolloutSettings {
|
|
12
|
-
boundaryEnforced: boolean;
|
|
13
|
-
endUsersLaunched: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Holds the in-flight/resolved request so that the settings are only fetched once per page load.
|
|
17
|
-
*/
|
|
18
|
-
export declare const cache: {
|
|
19
|
-
promise?: Promise<UnitsRolloutSettings>;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Reads the org's units rollout settings (`boundaryEnforced` and `endUsersLaunched`) from the
|
|
23
|
-
* TCS key exposed by AGG's `Query.admin_unitSettings`.
|
|
24
|
-
*
|
|
25
|
-
* The result is cached for the lifetime of the page because the settings only change when an
|
|
26
|
-
* admin activates or launches units, which requires a reload to be picked up anyway. A failed
|
|
27
|
-
* request is not cached so that a later call can retry.
|
|
28
|
-
*/
|
|
29
|
-
export declare const getUnitsRolloutSettings: () => Promise<UnitsRolloutSettings>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether unit isolation behaviour should be applied for the current org.
|
|
3
|
-
*
|
|
4
|
-
* An org is isolated when units GA is on, the org has been opted in to the rollout - either by
|
|
5
|
-
* org id or by cloud id - *and* the org has actually launched units with boundary enforcement
|
|
6
|
-
* turned on:
|
|
7
|
-
*
|
|
8
|
-
* `cc-units-ga on -> (orgId gate on || cloudId gate on) -> endUsersLaunched && boundaryEnforced -> isolate`
|
|
9
|
-
*
|
|
10
|
-
* `cc-units-ga` is the units GA master gate and acts as the killswitch: while it is off nothing
|
|
11
|
-
* else is evaluated and the current, non-isolated behaviour is kept. The AGG call is only made
|
|
12
|
-
* when one of the rollout gates passes, so orgs outside of the rollout do not pay for an extra
|
|
13
|
-
* request.
|
|
14
|
-
*/
|
|
15
|
-
export declare const isUnitsIsolationEnabled: () => Promise<boolean>;
|