@atlaskit/teams-client 4.31.1 → 4.32.1
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 +17 -0
- package/dist/cjs/services/base-client/index.js +3 -2
- package/dist/cjs/services/graphql-client/main.js +33 -1
- package/dist/cjs/services/legion-client/index.js +15 -11
- package/dist/es2019/services/base-client/index.js +3 -2
- package/dist/es2019/services/graphql-client/main.js +34 -1
- package/dist/es2019/services/legion-client/index.js +8 -2
- package/dist/esm/services/base-client/index.js +3 -2
- package/dist/esm/services/graphql-client/main.js +34 -1
- package/dist/esm/services/legion-client/index.js +15 -11
- package/dist/types/services/graphql-client/main.d.ts +4 -1
- package/dist/types/services/legion-client/index.d.ts +2 -0
- package/dist/types/services/legion-client/types.d.ts +1 -0
- package/dist/types-ts4.5/services/graphql-client/main.d.ts +4 -1
- package/dist/types-ts4.5/services/legion-client/index.d.ts +2 -0
- package/dist/types-ts4.5/services/legion-client/types.d.ts +1 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/teams-client
|
|
2
2
|
|
|
3
|
+
## 4.32.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a45dd5a6666e8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a45dd5a6666e8) -
|
|
8
|
+
Fix invalid ARI being sent in X-Query-Context header when cloudId is unavailable. Previously, an
|
|
9
|
+
uninitialised cloudId defaulted to the string 'None', causing requests to include a malformed
|
|
10
|
+
header value of `ari:cloud:platform::site/None`. The client now defaults to an empty string so no
|
|
11
|
+
header is sent until a valid cloudId is set.
|
|
12
|
+
|
|
13
|
+
## 4.32.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [`2f909e7624d7f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2f909e7624d7f) -
|
|
18
|
+
Align getAllTeams request with pagination parameter
|
|
19
|
+
|
|
3
20
|
## 4.31.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -8,6 +8,7 @@ exports.BaseClient = void 0;
|
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _sentry = require("../sentry");
|
|
12
13
|
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; }
|
|
13
14
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -22,14 +23,14 @@ var BaseClient = exports.BaseClient = /*#__PURE__*/function () {
|
|
|
22
23
|
});
|
|
23
24
|
this.config = config;
|
|
24
25
|
this.context = {
|
|
25
|
-
cloudId: 'None'
|
|
26
|
+
cloudId: (0, _platformFeatureFlags.fg)('teams-app_client_fix-invalid-ari') ? '' : 'None'
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
return (0, _createClass2.default)(BaseClient, [{
|
|
29
30
|
key: "setContext",
|
|
30
31
|
value: function setContext(context) {
|
|
31
32
|
this.context = _objectSpread(_objectSpread({}, context), {}, {
|
|
32
|
-
cloudId: context.cloudId || 'None'
|
|
33
|
+
cloudId: (0, _platformFeatureFlags.fg)('teams-app_client_fix-invalid-ari') ? context.cloudId || '' : context.cloudId || 'None'
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
}, {
|
|
@@ -13,6 +13,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
13
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
15
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _error = require("../../common/utils/error");
|
|
17
18
|
var _baseClient = require("../base-client");
|
|
18
19
|
var _utils = require("./utils");
|
|
@@ -20,6 +21,24 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
20
21
|
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) { (0, _defineProperty2.default)(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; }
|
|
21
22
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
22
23
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
24
|
+
/**
|
|
25
|
+
* Validates that a siteId (cloudId) conforms to the format expected by
|
|
26
|
+
* PlatformSiteAri from `@atlassian/ari/platform`.
|
|
27
|
+
*
|
|
28
|
+
* We inline this instead of importing `@atlassian/ari` because that package
|
|
29
|
+
* is private and `teams-client` is a public package - public packages cannot
|
|
30
|
+
* depend on private packages.
|
|
31
|
+
*
|
|
32
|
+
* The regex matches the `resourceIdSegmentFormats.siteId` rule from the
|
|
33
|
+
* PlatformSiteAri manifest: `/[a-zA-Z0-9_\-.]{1,255}/`
|
|
34
|
+
*/
|
|
35
|
+
var SITE_ID_PATTERN = /^[a-zA-Z0-9_\-.]{1,255}$/;
|
|
36
|
+
function createPlatformSiteAri(siteId) {
|
|
37
|
+
if (!SITE_ID_PATTERN.test(siteId)) {
|
|
38
|
+
throw new Error("Invalid siteId: ".concat(siteId));
|
|
39
|
+
}
|
|
40
|
+
return "ari:cloud:platform::site/".concat(siteId);
|
|
41
|
+
}
|
|
23
42
|
var BaseGraphQlClient = exports.BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
|
|
24
43
|
function BaseGraphQlClient(serviceUrl, config) {
|
|
25
44
|
var _this;
|
|
@@ -36,7 +55,10 @@ var BaseGraphQlClient = exports.BaseGraphQlClient = /*#__PURE__*/function (_Base
|
|
|
36
55
|
}
|
|
37
56
|
|
|
38
57
|
/**
|
|
39
|
-
* Creates query context headers if cloudId is available.
|
|
58
|
+
* Creates query context headers if cloudId is available and valid.
|
|
59
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
60
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
61
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
40
62
|
*/
|
|
41
63
|
}, {
|
|
42
64
|
key: "createQueryContextHeaders",
|
|
@@ -44,6 +66,16 @@ var BaseGraphQlClient = exports.BaseGraphQlClient = /*#__PURE__*/function (_Base
|
|
|
44
66
|
if (!cloudId) {
|
|
45
67
|
return undefined;
|
|
46
68
|
}
|
|
69
|
+
if ((0, _platformFeatureFlags.fg)('teams-app_client_fix-invalid-ari')) {
|
|
70
|
+
try {
|
|
71
|
+
var ari = createPlatformSiteAri(cloudId);
|
|
72
|
+
return {
|
|
73
|
+
'X-Query-Context': ari
|
|
74
|
+
};
|
|
75
|
+
} catch (_unused) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
47
79
|
return {
|
|
48
80
|
'X-Query-Context': "ari:cloud:platform::site/".concat(cloudId)
|
|
49
81
|
};
|
|
@@ -33,6 +33,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
33
33
|
* @property {boolean} useDefaultSort - Whether to use the default sort order
|
|
34
34
|
* @property {boolean} showEmptyTeams - Whether to return empty teams in the search
|
|
35
35
|
* @property {string[]} teamTypeIdsFilter - List of team type IDs to filter teams
|
|
36
|
+
* @property {boolean} enablePagination - Whether the API should paginate the response
|
|
36
37
|
*/
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -110,20 +111,20 @@ var LegionClient = exports.LegionClient = /*#__PURE__*/function (_RestClient) {
|
|
|
110
111
|
value: function () {
|
|
111
112
|
var _getAllTeams = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(allTeamsQuery) {
|
|
112
113
|
var _this2 = this;
|
|
113
|
-
var _orgId, _siteId, _yield$this$postResou, entities, _cursor, teams;
|
|
114
|
+
var _allTeamsQuery$enable, _orgId, _siteId, enablePagination, _yield$this$postResou, entities, _cursor, teams;
|
|
114
115
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
115
116
|
while (1) switch (_context2.prev = _context2.next) {
|
|
116
117
|
case 0:
|
|
117
118
|
_context2.prev = 0;
|
|
118
119
|
_orgId = this.getOrgId(allTeamsQuery.orgId);
|
|
119
120
|
_siteId = this.getCloudId();
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
enablePagination = (_allTeamsQuery$enable = allTeamsQuery.enablePagination) !== null && _allTeamsQuery$enable !== void 0 ? _allTeamsQuery$enable : true;
|
|
122
|
+
_context2.next = 6;
|
|
123
|
+
return this.postResource("".concat(v4UrlPath, "/search"), _objectSpread({
|
|
122
124
|
organizationId: _orgId,
|
|
123
125
|
siteId: _siteId,
|
|
124
126
|
limit: allTeamsQuery.limit,
|
|
125
127
|
query: allTeamsQuery.searchQuery,
|
|
126
|
-
cursor: allTeamsQuery.cursor || '',
|
|
127
128
|
sortBy: allTeamsQuery.useDefaultSort ? null : allTeamsQuery.sortBy && allTeamsQuery.sortBy.length > 0 ? allTeamsQuery.sortBy : [{
|
|
128
129
|
field: 'displayName',
|
|
129
130
|
order: 'asc'
|
|
@@ -132,9 +133,12 @@ var LegionClient = exports.LegionClient = /*#__PURE__*/function (_RestClient) {
|
|
|
132
133
|
memberAccountIds: allTeamsQuery.memberAccountIds
|
|
133
134
|
},
|
|
134
135
|
showEmptyTeams: allTeamsQuery.showEmptyTeams,
|
|
135
|
-
teamTypeIdsFilter: allTeamsQuery.teamTypeIdsFilter
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
teamTypeIdsFilter: allTeamsQuery.teamTypeIdsFilter,
|
|
137
|
+
enablePagination: enablePagination
|
|
138
|
+
}, enablePagination && allTeamsQuery.cursor ? {
|
|
139
|
+
cursor: allTeamsQuery.cursor
|
|
140
|
+
} : {}));
|
|
141
|
+
case 6:
|
|
138
142
|
_yield$this$postResou = _context2.sent;
|
|
139
143
|
entities = _yield$this$postResou.entities;
|
|
140
144
|
_cursor = _yield$this$postResou.cursor;
|
|
@@ -145,8 +149,8 @@ var LegionClient = exports.LegionClient = /*#__PURE__*/function (_RestClient) {
|
|
|
145
149
|
cursor: _cursor,
|
|
146
150
|
teams: teams
|
|
147
151
|
});
|
|
148
|
-
case
|
|
149
|
-
_context2.prev =
|
|
152
|
+
case 13:
|
|
153
|
+
_context2.prev = 13;
|
|
150
154
|
_context2.t0 = _context2["catch"](0);
|
|
151
155
|
this.logException(_context2.t0, 'getAllTeams');
|
|
152
156
|
return _context2.abrupt("return", {
|
|
@@ -154,11 +158,11 @@ var LegionClient = exports.LegionClient = /*#__PURE__*/function (_RestClient) {
|
|
|
154
158
|
teams: [],
|
|
155
159
|
error: _context2.t0 instanceof Error ? _context2.t0 : undefined
|
|
156
160
|
});
|
|
157
|
-
case
|
|
161
|
+
case 17:
|
|
158
162
|
case "end":
|
|
159
163
|
return _context2.stop();
|
|
160
164
|
}
|
|
161
|
-
}, _callee2, this, [[0,
|
|
165
|
+
}, _callee2, this, [[0, 13]]);
|
|
162
166
|
}));
|
|
163
167
|
function getAllTeams(_x3) {
|
|
164
168
|
return _getAllTeams.apply(this, arguments);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { logException } from '../sentry';
|
|
3
4
|
export class BaseClient {
|
|
4
5
|
constructor(config) {
|
|
@@ -9,13 +10,13 @@ export class BaseClient {
|
|
|
9
10
|
});
|
|
10
11
|
this.config = config;
|
|
11
12
|
this.context = {
|
|
12
|
-
cloudId: 'None'
|
|
13
|
+
cloudId: fg('teams-app_client_fix-invalid-ari') ? '' : 'None'
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
setContext(context) {
|
|
16
17
|
this.context = {
|
|
17
18
|
...context,
|
|
18
|
-
cloudId: context.cloudId || 'None'
|
|
19
|
+
cloudId: fg('teams-app_client_fix-invalid-ari') ? context.cloudId || '' : context.cloudId || 'None'
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
getContext() {
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import { DefaultError, GraphQLError } from '../../common/utils/error';
|
|
2
3
|
import { BaseClient } from '../base-client';
|
|
3
4
|
import { handleGraphQLRequest } from './utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Validates that a siteId (cloudId) conforms to the format expected by
|
|
8
|
+
* PlatformSiteAri from `@atlassian/ari/platform`.
|
|
9
|
+
*
|
|
10
|
+
* We inline this instead of importing `@atlassian/ari` because that package
|
|
11
|
+
* is private and `teams-client` is a public package - public packages cannot
|
|
12
|
+
* depend on private packages.
|
|
13
|
+
*
|
|
14
|
+
* The regex matches the `resourceIdSegmentFormats.siteId` rule from the
|
|
15
|
+
* PlatformSiteAri manifest: `/[a-zA-Z0-9_\-.]{1,255}/`
|
|
16
|
+
*/
|
|
17
|
+
const SITE_ID_PATTERN = /^[a-zA-Z0-9_\-.]{1,255}$/;
|
|
18
|
+
function createPlatformSiteAri(siteId) {
|
|
19
|
+
if (!SITE_ID_PATTERN.test(siteId)) {
|
|
20
|
+
throw new Error(`Invalid siteId: ${siteId}`);
|
|
21
|
+
}
|
|
22
|
+
return `ari:cloud:platform::site/${siteId}`;
|
|
23
|
+
}
|
|
4
24
|
export class BaseGraphQlClient extends BaseClient {
|
|
5
25
|
constructor(serviceUrl, config) {
|
|
6
26
|
super(config);
|
|
@@ -11,12 +31,25 @@ export class BaseGraphQlClient extends BaseClient {
|
|
|
11
31
|
}
|
|
12
32
|
|
|
13
33
|
/**
|
|
14
|
-
* Creates query context headers if cloudId is available.
|
|
34
|
+
* Creates query context headers if cloudId is available and valid.
|
|
35
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
36
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
37
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
15
38
|
*/
|
|
16
39
|
createQueryContextHeaders(cloudId) {
|
|
17
40
|
if (!cloudId) {
|
|
18
41
|
return undefined;
|
|
19
42
|
}
|
|
43
|
+
if (fg('teams-app_client_fix-invalid-ari')) {
|
|
44
|
+
try {
|
|
45
|
+
const ari = createPlatformSiteAri(cloudId);
|
|
46
|
+
return {
|
|
47
|
+
'X-Query-Context': ari
|
|
48
|
+
};
|
|
49
|
+
} catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
20
53
|
return {
|
|
21
54
|
'X-Query-Context': `ari:cloud:platform::site/${cloudId}`
|
|
22
55
|
};
|
|
@@ -12,6 +12,7 @@ import { RestClient } from '../rest-client';
|
|
|
12
12
|
* @property {boolean} useDefaultSort - Whether to use the default sort order
|
|
13
13
|
* @property {boolean} showEmptyTeams - Whether to return empty teams in the search
|
|
14
14
|
* @property {string[]} teamTypeIdsFilter - List of team type IDs to filter teams
|
|
15
|
+
* @property {boolean} enablePagination - Whether the API should paginate the response
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -60,8 +61,10 @@ export class LegionClient extends RestClient {
|
|
|
60
61
|
}
|
|
61
62
|
async getAllTeams(allTeamsQuery) {
|
|
62
63
|
try {
|
|
64
|
+
var _allTeamsQuery$enable;
|
|
63
65
|
const orgId = this.getOrgId(allTeamsQuery.orgId);
|
|
64
66
|
const siteId = this.getCloudId();
|
|
67
|
+
const enablePagination = (_allTeamsQuery$enable = allTeamsQuery.enablePagination) !== null && _allTeamsQuery$enable !== void 0 ? _allTeamsQuery$enable : true;
|
|
65
68
|
const {
|
|
66
69
|
entities,
|
|
67
70
|
cursor
|
|
@@ -70,7 +73,6 @@ export class LegionClient extends RestClient {
|
|
|
70
73
|
siteId: siteId,
|
|
71
74
|
limit: allTeamsQuery.limit,
|
|
72
75
|
query: allTeamsQuery.searchQuery,
|
|
73
|
-
cursor: allTeamsQuery.cursor || '',
|
|
74
76
|
sortBy: allTeamsQuery.useDefaultSort ? null : allTeamsQuery.sortBy && allTeamsQuery.sortBy.length > 0 ? allTeamsQuery.sortBy : [{
|
|
75
77
|
field: 'displayName',
|
|
76
78
|
order: 'asc'
|
|
@@ -79,7 +81,11 @@ export class LegionClient extends RestClient {
|
|
|
79
81
|
memberAccountIds: allTeamsQuery.memberAccountIds
|
|
80
82
|
},
|
|
81
83
|
showEmptyTeams: allTeamsQuery.showEmptyTeams,
|
|
82
|
-
teamTypeIdsFilter: allTeamsQuery.teamTypeIdsFilter
|
|
84
|
+
teamTypeIdsFilter: allTeamsQuery.teamTypeIdsFilter,
|
|
85
|
+
enablePagination,
|
|
86
|
+
...(enablePagination && allTeamsQuery.cursor ? {
|
|
87
|
+
cursor: allTeamsQuery.cursor
|
|
88
|
+
} : {})
|
|
83
89
|
});
|
|
84
90
|
const teams = entities.map(t => this.mapTeamSearchResponseV4ToTeamWithMembership(t));
|
|
85
91
|
return {
|
|
@@ -3,6 +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 { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { logException } from '../sentry';
|
|
7
8
|
export var BaseClient = /*#__PURE__*/function () {
|
|
8
9
|
function BaseClient(config) {
|
|
@@ -15,14 +16,14 @@ export var BaseClient = /*#__PURE__*/function () {
|
|
|
15
16
|
});
|
|
16
17
|
this.config = config;
|
|
17
18
|
this.context = {
|
|
18
|
-
cloudId: 'None'
|
|
19
|
+
cloudId: fg('teams-app_client_fix-invalid-ari') ? '' : 'None'
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
return _createClass(BaseClient, [{
|
|
22
23
|
key: "setContext",
|
|
23
24
|
value: function setContext(context) {
|
|
24
25
|
this.context = _objectSpread(_objectSpread({}, context), {}, {
|
|
25
|
-
cloudId: context.cloudId || 'None'
|
|
26
|
+
cloudId: fg('teams-app_client_fix-invalid-ari') ? context.cloudId || '' : context.cloudId || 'None'
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
}, {
|
|
@@ -10,9 +10,29 @@ 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';
|
|
13
14
|
import { DefaultError, GraphQLError } from '../../common/utils/error';
|
|
14
15
|
import { BaseClient } from '../base-client';
|
|
15
16
|
import { handleGraphQLRequest } from './utils';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validates that a siteId (cloudId) conforms to the format expected by
|
|
20
|
+
* PlatformSiteAri from `@atlassian/ari/platform`.
|
|
21
|
+
*
|
|
22
|
+
* We inline this instead of importing `@atlassian/ari` because that package
|
|
23
|
+
* is private and `teams-client` is a public package - public packages cannot
|
|
24
|
+
* depend on private packages.
|
|
25
|
+
*
|
|
26
|
+
* The regex matches the `resourceIdSegmentFormats.siteId` rule from the
|
|
27
|
+
* PlatformSiteAri manifest: `/[a-zA-Z0-9_\-.]{1,255}/`
|
|
28
|
+
*/
|
|
29
|
+
var SITE_ID_PATTERN = /^[a-zA-Z0-9_\-.]{1,255}$/;
|
|
30
|
+
function createPlatformSiteAri(siteId) {
|
|
31
|
+
if (!SITE_ID_PATTERN.test(siteId)) {
|
|
32
|
+
throw new Error("Invalid siteId: ".concat(siteId));
|
|
33
|
+
}
|
|
34
|
+
return "ari:cloud:platform::site/".concat(siteId);
|
|
35
|
+
}
|
|
16
36
|
export var BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
|
|
17
37
|
function BaseGraphQlClient(serviceUrl, config) {
|
|
18
38
|
var _this;
|
|
@@ -29,7 +49,10 @@ export var BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
29
49
|
}
|
|
30
50
|
|
|
31
51
|
/**
|
|
32
|
-
* Creates query context headers if cloudId is available.
|
|
52
|
+
* Creates query context headers if cloudId is available and valid.
|
|
53
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
54
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
55
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
33
56
|
*/
|
|
34
57
|
}, {
|
|
35
58
|
key: "createQueryContextHeaders",
|
|
@@ -37,6 +60,16 @@ export var BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
37
60
|
if (!cloudId) {
|
|
38
61
|
return undefined;
|
|
39
62
|
}
|
|
63
|
+
if (fg('teams-app_client_fix-invalid-ari')) {
|
|
64
|
+
try {
|
|
65
|
+
var ari = createPlatformSiteAri(cloudId);
|
|
66
|
+
return {
|
|
67
|
+
'X-Query-Context': ari
|
|
68
|
+
};
|
|
69
|
+
} catch (_unused) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
40
73
|
return {
|
|
41
74
|
'X-Query-Context': "ari:cloud:platform::site/".concat(cloudId)
|
|
42
75
|
};
|
|
@@ -27,6 +27,7 @@ import { RestClient } from '../rest-client';
|
|
|
27
27
|
* @property {boolean} useDefaultSort - Whether to use the default sort order
|
|
28
28
|
* @property {boolean} showEmptyTeams - Whether to return empty teams in the search
|
|
29
29
|
* @property {string[]} teamTypeIdsFilter - List of team type IDs to filter teams
|
|
30
|
+
* @property {boolean} enablePagination - Whether the API should paginate the response
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -104,20 +105,20 @@ export var LegionClient = /*#__PURE__*/function (_RestClient) {
|
|
|
104
105
|
value: function () {
|
|
105
106
|
var _getAllTeams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(allTeamsQuery) {
|
|
106
107
|
var _this2 = this;
|
|
107
|
-
var _orgId, _siteId, _yield$this$postResou, entities, _cursor, teams;
|
|
108
|
+
var _allTeamsQuery$enable, _orgId, _siteId, enablePagination, _yield$this$postResou, entities, _cursor, teams;
|
|
108
109
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
109
110
|
while (1) switch (_context2.prev = _context2.next) {
|
|
110
111
|
case 0:
|
|
111
112
|
_context2.prev = 0;
|
|
112
113
|
_orgId = this.getOrgId(allTeamsQuery.orgId);
|
|
113
114
|
_siteId = this.getCloudId();
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
enablePagination = (_allTeamsQuery$enable = allTeamsQuery.enablePagination) !== null && _allTeamsQuery$enable !== void 0 ? _allTeamsQuery$enable : true;
|
|
116
|
+
_context2.next = 6;
|
|
117
|
+
return this.postResource("".concat(v4UrlPath, "/search"), _objectSpread({
|
|
116
118
|
organizationId: _orgId,
|
|
117
119
|
siteId: _siteId,
|
|
118
120
|
limit: allTeamsQuery.limit,
|
|
119
121
|
query: allTeamsQuery.searchQuery,
|
|
120
|
-
cursor: allTeamsQuery.cursor || '',
|
|
121
122
|
sortBy: allTeamsQuery.useDefaultSort ? null : allTeamsQuery.sortBy && allTeamsQuery.sortBy.length > 0 ? allTeamsQuery.sortBy : [{
|
|
122
123
|
field: 'displayName',
|
|
123
124
|
order: 'asc'
|
|
@@ -126,9 +127,12 @@ export var LegionClient = /*#__PURE__*/function (_RestClient) {
|
|
|
126
127
|
memberAccountIds: allTeamsQuery.memberAccountIds
|
|
127
128
|
},
|
|
128
129
|
showEmptyTeams: allTeamsQuery.showEmptyTeams,
|
|
129
|
-
teamTypeIdsFilter: allTeamsQuery.teamTypeIdsFilter
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
teamTypeIdsFilter: allTeamsQuery.teamTypeIdsFilter,
|
|
131
|
+
enablePagination: enablePagination
|
|
132
|
+
}, enablePagination && allTeamsQuery.cursor ? {
|
|
133
|
+
cursor: allTeamsQuery.cursor
|
|
134
|
+
} : {}));
|
|
135
|
+
case 6:
|
|
132
136
|
_yield$this$postResou = _context2.sent;
|
|
133
137
|
entities = _yield$this$postResou.entities;
|
|
134
138
|
_cursor = _yield$this$postResou.cursor;
|
|
@@ -139,8 +143,8 @@ export var LegionClient = /*#__PURE__*/function (_RestClient) {
|
|
|
139
143
|
cursor: _cursor,
|
|
140
144
|
teams: teams
|
|
141
145
|
});
|
|
142
|
-
case
|
|
143
|
-
_context2.prev =
|
|
146
|
+
case 13:
|
|
147
|
+
_context2.prev = 13;
|
|
144
148
|
_context2.t0 = _context2["catch"](0);
|
|
145
149
|
this.logException(_context2.t0, 'getAllTeams');
|
|
146
150
|
return _context2.abrupt("return", {
|
|
@@ -148,11 +152,11 @@ export var LegionClient = /*#__PURE__*/function (_RestClient) {
|
|
|
148
152
|
teams: [],
|
|
149
153
|
error: _context2.t0 instanceof Error ? _context2.t0 : undefined
|
|
150
154
|
});
|
|
151
|
-
case
|
|
155
|
+
case 17:
|
|
152
156
|
case "end":
|
|
153
157
|
return _context2.stop();
|
|
154
158
|
}
|
|
155
|
-
}, _callee2, this, [[0,
|
|
159
|
+
}, _callee2, this, [[0, 13]]);
|
|
156
160
|
}));
|
|
157
161
|
function getAllTeams(_x3) {
|
|
158
162
|
return _getAllTeams.apply(this, arguments);
|
|
@@ -5,7 +5,10 @@ export declare class BaseGraphQlClient extends BaseClient {
|
|
|
5
5
|
constructor(serviceUrl: string, config: ClientConfig);
|
|
6
6
|
setServiceUrl(serviceUrl: string): void;
|
|
7
7
|
/**
|
|
8
|
-
* Creates query context headers if cloudId is available.
|
|
8
|
+
* Creates query context headers if cloudId is available and valid.
|
|
9
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
10
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
11
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
9
12
|
*/
|
|
10
13
|
private createQueryContextHeaders;
|
|
11
14
|
makeGraphQLRequest<Key extends string, Data = unknown, Variables = unknown>(body: Body<Variables>, options?: Options): Promise<ResultResponse<Key, Data>>;
|
|
@@ -30,6 +30,7 @@ export interface SortField {
|
|
|
30
30
|
* @property {boolean} useDefaultSort - Whether to use the default sort order
|
|
31
31
|
* @property {boolean} showEmptyTeams - Whether to return empty teams in the search
|
|
32
32
|
* @property {string[]} teamTypeIdsFilter - List of team type IDs to filter teams
|
|
33
|
+
* @property {boolean} enablePagination - Whether the API should paginate the response
|
|
33
34
|
*/
|
|
34
35
|
export interface AllTeamsQuery {
|
|
35
36
|
/**
|
|
@@ -45,6 +46,7 @@ export interface AllTeamsQuery {
|
|
|
45
46
|
showEmptyTeams?: boolean;
|
|
46
47
|
sortBy?: SortField[];
|
|
47
48
|
teamTypeIdsFilter?: string[];
|
|
49
|
+
enablePagination?: boolean;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* @type AllTeamsResponse
|
|
@@ -5,7 +5,10 @@ export declare class BaseGraphQlClient extends BaseClient {
|
|
|
5
5
|
constructor(serviceUrl: string, config: ClientConfig);
|
|
6
6
|
setServiceUrl(serviceUrl: string): void;
|
|
7
7
|
/**
|
|
8
|
-
* Creates query context headers if cloudId is available.
|
|
8
|
+
* Creates query context headers if cloudId is available and valid.
|
|
9
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
10
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
11
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
9
12
|
*/
|
|
10
13
|
private createQueryContextHeaders;
|
|
11
14
|
makeGraphQLRequest<Key extends string, Data = unknown, Variables = unknown>(body: Body<Variables>, options?: Options): Promise<ResultResponse<Key, Data>>;
|
|
@@ -30,6 +30,7 @@ export interface SortField {
|
|
|
30
30
|
* @property {boolean} useDefaultSort - Whether to use the default sort order
|
|
31
31
|
* @property {boolean} showEmptyTeams - Whether to return empty teams in the search
|
|
32
32
|
* @property {string[]} teamTypeIdsFilter - List of team type IDs to filter teams
|
|
33
|
+
* @property {boolean} enablePagination - Whether the API should paginate the response
|
|
33
34
|
*/
|
|
34
35
|
export interface AllTeamsQuery {
|
|
35
36
|
/**
|
|
@@ -45,6 +46,7 @@ export interface AllTeamsQuery {
|
|
|
45
46
|
showEmptyTeams?: boolean;
|
|
46
47
|
sortBy?: SortField[];
|
|
47
48
|
teamTypeIdsFilter?: string[];
|
|
49
|
+
enablePagination?: boolean;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* @type AllTeamsResponse
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/teams-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.32.1",
|
|
4
4
|
"description": "A client to retrieve team related data",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -93,6 +93,9 @@
|
|
|
93
93
|
"platform-feature-flags": {
|
|
94
94
|
"enable_edit_team_name_external_type_teams": {
|
|
95
95
|
"type": "boolean"
|
|
96
|
+
},
|
|
97
|
+
"teams-app_client_fix-invalid-ari": {
|
|
98
|
+
"type": "boolean"
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
}
|