@commercetools-frontend/application-shell-connectors 27.10.0 → 27.11.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.
@@ -78,7 +78,7 @@ var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construc
78
78
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
79
79
 
80
80
  // NOTE: This string will be replaced on build time with the package version.
81
- var version = "27.10.0";
81
+ var version = "27.11.0";
82
82
 
83
83
  // From https://github.com/acdlite/recompose/blob/master/src/packages/recompose/getDisplayName.js
84
84
  const getDisplayName = Component => {
@@ -267,6 +267,7 @@ const mapUserToApplicationContextUser = user => {
267
267
  firstName: user.firstName,
268
268
  lastName: user.lastName,
269
269
  businessRole: user.businessRole,
270
+ isAdminOfAnyOrganization: user.isAdminOfAnyOrganization ?? false,
270
271
  // NOTE: this is an alias for the original field `user.language` but it's actually
271
272
  // a locale (language + country).
272
273
  locale: user.language,
@@ -585,11 +586,9 @@ function selectTeamIdFromStorage() {
585
586
  return window.sessionStorage.getItem(constants.STORAGE_KEYS.ACTIVE_TEAM_ID) || window.app.__DEVELOPMENT__?.oidc?.teamId;
586
587
  }
587
588
 
588
- const staticUrlPathsInPositionOfProjectKey = ['login', 'logout', 'account'];
589
-
590
589
  // Attempt to extract the `:projectKey` from the URL.
591
- // If the value matches one of the values in the list above,
592
- // return `undefined` as we're not within a project context.
590
+ // If the value matches one of the static URL paths in the position of the
591
+ // project key, return `undefined` as we're not within a project context.
593
592
  function selectProjectKeyFromUrl() {
594
593
  let locationPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.pathname;
595
594
  let possibleProjectKey = '';
@@ -601,7 +600,7 @@ function selectProjectKeyFromUrl() {
601
600
  // Application paths: /:projectKey/:applicationId
602
601
  possibleProjectKey = pathParts[1];
603
602
  }
604
- return _includesInstanceProperty__default["default"](staticUrlPathsInPositionOfProjectKey).call(staticUrlPathsInPositionOfProjectKey, possibleProjectKey) ? undefined : possibleProjectKey;
603
+ return constants.isStaticUrlPathInPositionOfProjectKey(possibleProjectKey) ? undefined : possibleProjectKey;
605
604
  }
606
605
 
607
606
  // Keep an in-memory reference to the apollo client that would be initialized
@@ -77,7 +77,7 @@ var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construc
77
77
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
78
78
 
79
79
  // NOTE: This string will be replaced on build time with the package version.
80
- var version = "27.10.0";
80
+ var version = "27.11.0";
81
81
 
82
82
  // From https://github.com/acdlite/recompose/blob/master/src/packages/recompose/getDisplayName.js
83
83
  const getDisplayName = Component => {
@@ -266,6 +266,7 @@ const mapUserToApplicationContextUser = user => {
266
266
  firstName: user.firstName,
267
267
  lastName: user.lastName,
268
268
  businessRole: user.businessRole,
269
+ isAdminOfAnyOrganization: user.isAdminOfAnyOrganization ?? false,
269
270
  // NOTE: this is an alias for the original field `user.language` but it's actually
270
271
  // a locale (language + country).
271
272
  locale: user.language,
@@ -583,11 +584,9 @@ function selectTeamIdFromStorage() {
583
584
  return window.sessionStorage.getItem(constants.STORAGE_KEYS.ACTIVE_TEAM_ID) || window.app.__DEVELOPMENT__?.oidc?.teamId;
584
585
  }
585
586
 
586
- const staticUrlPathsInPositionOfProjectKey = ['login', 'logout', 'account'];
587
-
588
587
  // Attempt to extract the `:projectKey` from the URL.
589
- // If the value matches one of the values in the list above,
590
- // return `undefined` as we're not within a project context.
588
+ // If the value matches one of the static URL paths in the position of the
589
+ // project key, return `undefined` as we're not within a project context.
591
590
  function selectProjectKeyFromUrl() {
592
591
  let locationPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.pathname;
593
592
  let possibleProjectKey = '';
@@ -599,7 +598,7 @@ function selectProjectKeyFromUrl() {
599
598
  // Application paths: /:projectKey/:applicationId
600
599
  possibleProjectKey = pathParts[1];
601
600
  }
602
- return _includesInstanceProperty__default["default"](staticUrlPathsInPositionOfProjectKey).call(staticUrlPathsInPositionOfProjectKey, possibleProjectKey) ? undefined : possibleProjectKey;
601
+ return constants.isStaticUrlPathInPositionOfProjectKey(possibleProjectKey) ? undefined : possibleProjectKey;
603
602
  }
604
603
 
605
604
  // Keep an in-memory reference to the apollo client that would be initialized
@@ -17,7 +17,7 @@ import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entrie
17
17
  import _valuesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/values';
18
18
  import { jsx } from '@emotion/react/jsx-runtime';
19
19
  import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
20
- import { CUSTOM_VIEWS_EVENTS_NAMES, GRAPHQL_TARGETS, SUPPORTED_HEADERS, STATUS_CODES, LOGOUT_REASONS, STORAGE_KEYS, LOGIN_STRATEGY_OIDC } from '@commercetools-frontend/constants';
20
+ import { CUSTOM_VIEWS_EVENTS_NAMES, GRAPHQL_TARGETS, SUPPORTED_HEADERS, STATUS_CODES, LOGOUT_REASONS, STORAGE_KEYS, isStaticUrlPathInPositionOfProjectKey, LOGIN_STRATEGY_OIDC } from '@commercetools-frontend/constants';
21
21
  import { useQuery, useLazyQuery, useMutation } from '@apollo/client/react';
22
22
  import warning from 'tiny-warning';
23
23
  import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
@@ -44,7 +44,7 @@ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringif
44
44
  import { RetryLink } from '@apollo/client/link/retry';
45
45
 
46
46
  // NOTE: This string will be replaced on build time with the package version.
47
- var version = "27.10.0";
47
+ var version = "27.11.0";
48
48
 
49
49
  // From https://github.com/acdlite/recompose/blob/master/src/packages/recompose/getDisplayName.js
50
50
  const getDisplayName = Component => {
@@ -233,6 +233,7 @@ const mapUserToApplicationContextUser = user => {
233
233
  firstName: user.firstName,
234
234
  lastName: user.lastName,
235
235
  businessRole: user.businessRole,
236
+ isAdminOfAnyOrganization: user.isAdminOfAnyOrganization ?? false,
236
237
  // NOTE: this is an alias for the original field `user.language` but it's actually
237
238
  // a locale (language + country).
238
239
  locale: user.language,
@@ -551,11 +552,9 @@ function selectTeamIdFromStorage() {
551
552
  return window.sessionStorage.getItem(STORAGE_KEYS.ACTIVE_TEAM_ID) || window.app.__DEVELOPMENT__?.oidc?.teamId;
552
553
  }
553
554
 
554
- const staticUrlPathsInPositionOfProjectKey = ['login', 'logout', 'account'];
555
-
556
555
  // Attempt to extract the `:projectKey` from the URL.
557
- // If the value matches one of the values in the list above,
558
- // return `undefined` as we're not within a project context.
556
+ // If the value matches one of the static URL paths in the position of the
557
+ // project key, return `undefined` as we're not within a project context.
559
558
  function selectProjectKeyFromUrl() {
560
559
  let locationPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.pathname;
561
560
  let possibleProjectKey = '';
@@ -567,7 +566,7 @@ function selectProjectKeyFromUrl() {
567
566
  // Application paths: /:projectKey/:applicationId
568
567
  possibleProjectKey = pathParts[1];
569
568
  }
570
- return _includesInstanceProperty(staticUrlPathsInPositionOfProjectKey).call(staticUrlPathsInPositionOfProjectKey, possibleProjectKey) ? undefined : possibleProjectKey;
569
+ return isStaticUrlPathInPositionOfProjectKey(possibleProjectKey) ? undefined : possibleProjectKey;
571
570
  }
572
571
 
573
572
  // Keep an in-memory reference to the apollo client that would be initialized
@@ -34,6 +34,10 @@ type TApplicationContextDataFenceType = 'store';
34
34
  type TApplicationContextDataFences = Partial<Record<TApplicationContextDataFenceType, TApplicationContextGroupedByResourceType>>;
35
35
  type TApplicationContextEnvironment = ApplicationWindow['app'];
36
36
  type TApplicationContextUser = Pick<NonNullable<TFetchedUser>, 'id' | 'email' | 'createdAt' | 'firstName' | 'lastName' | 'businessRole' | 'projects'> & {
37
+ /**
38
+ * Indicates whether the user is an admin of at least one organization.
39
+ */
40
+ isAdminOfAnyOrganization: boolean;
37
41
  locale: string;
38
42
  timeZone: string;
39
43
  idTokenUserInfo?: Omit<TIdTokenUserInfo, 'additionalClaims'> & {
@@ -18,11 +18,99 @@ export type Scalars = {
18
18
  Boolean: boolean;
19
19
  Int: number;
20
20
  Float: number;
21
+ DateTime: any;
22
+ };
23
+ export declare enum TAiUsageAnalyticsAggregation {
24
+ Count = "COUNT",
25
+ CountDistinct = "COUNT_DISTINCT",
26
+ Max = "MAX",
27
+ Min = "MIN",
28
+ Sum = "SUM"
29
+ }
30
+ export type TAiUsageAnalyticsCounterBreakdownItem = {
31
+ __typename?: 'AIUsageAnalyticsCounterBreakdownItem';
32
+ key: Scalars['ID'];
33
+ value: Scalars['Float'];
34
+ };
35
+ export type TAiUsageAnalyticsCounterInput = {
36
+ aggregation: TAiUsageAnalyticsAggregation;
37
+ groupBy?: InputMaybe<TAiUsageAnalyticsGroupDimension>;
38
+ key: Scalars['String'];
39
+ measure: TAiUsageAnalyticsMeasure;
40
+ };
41
+ export type TAiUsageAnalyticsCounterResult = {
42
+ __typename?: 'AIUsageAnalyticsCounterResult';
43
+ aggregation: TAiUsageAnalyticsAggregation;
44
+ breakdown?: Maybe<Array<TAiUsageAnalyticsCounterBreakdownItem>>;
45
+ groupBy?: Maybe<TAiUsageAnalyticsGroupDimension>;
46
+ key: Scalars['String'];
47
+ measure: TAiUsageAnalyticsMeasure;
48
+ value?: Maybe<Scalars['Float']>;
49
+ };
50
+ export declare enum TAiUsageAnalyticsGroupDimension {
51
+ Agent = "AGENT"
52
+ }
53
+ export declare enum TAiUsageAnalyticsMeasure {
54
+ Requests = "REQUESTS",
55
+ Tokens = "TOKENS",
56
+ TokensIn = "TOKENS_IN",
57
+ TokensOut = "TOKENS_OUT"
58
+ }
59
+ export type TAiUsageAnalyticsPeriodInput = {
60
+ from: Scalars['DateTime'];
61
+ to: Scalars['DateTime'];
62
+ };
63
+ export type TAiUsageAnalyticsResult = {
64
+ __typename?: 'AIUsageAnalyticsResult';
65
+ /**
66
+ * The counters data for the given project keys and organization id.
67
+ * The counters are used to aggregate the data by a specific dimension.
68
+ * For example, the total number of requests, the total number of tokens, the total number of tokens in, the total number of tokens out,
69
+ * the total number of latency, etc.
70
+ */
71
+ counters: Array<TAiUsageAnalyticsCounterResult>;
72
+ /**
73
+ * The existence of the AI usage analytics feature. If there is no data for the given project keys and organization id,
74
+ * the existence will be `false`.
75
+ */
76
+ exists: Scalars['Boolean'];
77
+ /** The time series data for the given project keys and organization id. */
78
+ timeSeries: Array<TAiUsageAnalyticsTimeSeriesGroup>;
79
+ };
80
+ export type TAiUsageAnalyticsResult_CountersArgs = {
81
+ counters: Array<TAiUsageAnalyticsCounterInput>;
82
+ period: TAiUsageAnalyticsPeriodInput;
83
+ };
84
+ export type TAiUsageAnalyticsResult_TimeSeriesArgs = {
85
+ groupBy?: InputMaybe<TAiUsageAnalyticsGroupDimension>;
86
+ interval?: InputMaybe<TAiUsageAnalyticsTimeInterval>;
87
+ measure: TAiUsageAnalyticsMeasure;
88
+ period: TAiUsageAnalyticsPeriodInput;
89
+ };
90
+ export declare enum TAiUsageAnalyticsTimeInterval {
91
+ Day = "DAY",
92
+ Month = "MONTH",
93
+ Week = "WEEK"
94
+ }
95
+ export type TAiUsageAnalyticsTimeSeriesGroup = {
96
+ __typename?: 'AIUsageAnalyticsTimeSeriesGroup';
97
+ key: Scalars['ID'];
98
+ points: Array<TAiUsageAnalyticsTimeSeriesPoint>;
99
+ };
100
+ export type TAiUsageAnalyticsTimeSeriesPoint = {
101
+ __typename?: 'AIUsageAnalyticsTimeSeriesPoint';
102
+ timestamp: Scalars['DateTime'];
103
+ value: Scalars['Float'];
21
104
  };
22
105
  export type TAdditionalUserInfo = {
23
106
  firstName: Scalars['String'];
24
107
  lastName: Scalars['String'];
25
108
  };
109
+ export type TAgentCapability = {
110
+ __typename?: 'AgentCapability';
111
+ agentId: Scalars['String'];
112
+ requiredOAuthScopes: Array<Scalars['String']>;
113
+ };
26
114
  export type TAllPermissionsForAllApplications = {
27
115
  __typename?: 'AllPermissionsForAllApplications';
28
116
  allAppliedActionRights: Array<TAppliedActionRight>;
@@ -80,6 +168,15 @@ export type TDeletedUser = {
80
168
  __typename?: 'DeletedUser';
81
169
  id: Scalars['String'];
82
170
  };
171
+ export type TExportOrganizationMembersResult = {
172
+ __typename?: 'ExportOrganizationMembersResult';
173
+ /**
174
+ * The exported organization members as a CSV document. One row per user
175
+ * (deduplicated across teams), listing the user's email, the teams they belong
176
+ * to, and their last login timestamp in ISO 8601 UTC.
177
+ */
178
+ result: Scalars['String'];
179
+ };
83
180
  export type TFeature = {
84
181
  __typename?: 'Feature';
85
182
  name: Scalars['String'];
@@ -226,6 +323,7 @@ export type TOAuthClient = {
226
323
  createdAt?: Maybe<Scalars['String']>;
227
324
  id: Scalars['ID'];
228
325
  lastUsedAt?: Maybe<Scalars['String']>;
326
+ mcpScopes: Array<Scalars['String']>;
229
327
  name: Scalars['String'];
230
328
  ownerId: Scalars['ID'];
231
329
  permissions: Array<TProjectPermission>;
@@ -354,6 +452,12 @@ export declare enum TProjectSuspensionReason {
354
452
  }
355
453
  export type TQuery = {
356
454
  __typename?: 'Query';
455
+ agentRequiredCapabilities: Array<TAgentCapability>;
456
+ /**
457
+ * Returns the AI usage analytics for the given project key and organization id.
458
+ * Only administrators of the organization may call this query.
459
+ */
460
+ aiUsageAnalytics: TAiUsageAnalyticsResult;
357
461
  allFeatures: Array<TFeature>;
358
462
  allImpliedOAuthScopes: Array<Scalars['String']>;
359
463
  allSupportedActionRights?: Maybe<Array<TSupportedActionRight>>;
@@ -363,6 +467,11 @@ export type TQuery = {
363
467
  allSupportedResources?: Maybe<Array<TSupportedResource>>;
364
468
  allSupportedStoreScopes?: Maybe<Array<TSupportedStoreScope>>;
365
469
  amILoggedIn: Scalars['Boolean'];
470
+ /**
471
+ * Exports every member of every team in the given organization as a CSV
472
+ * document. Only administrators of the organization may call this query.
473
+ */
474
+ exportOrganizationMembers: TExportOrganizationMembersResult;
366
475
  invitation?: Maybe<TInvitationQueryResult>;
367
476
  me?: Maybe<TUser>;
368
477
  oAuthClient?: Maybe<TOAuthClient>;
@@ -374,10 +483,20 @@ export type TQuery = {
374
483
  storeOAuthScopes: Array<Scalars['String']>;
375
484
  systemStatus: TSystemStatus;
376
485
  };
486
+ export type TQuery_AgentRequiredCapabilitiesArgs = {
487
+ projectKey: Scalars['String'];
488
+ };
489
+ export type TQuery_AiUsageAnalyticsArgs = {
490
+ organizationId: Scalars['ID'];
491
+ projectKey: Scalars['String'];
492
+ };
377
493
  export type TQuery_AllImpliedOAuthScopesArgs = {
378
494
  onlyConfiguredOnTrustedClient?: InputMaybe<Scalars['Boolean']>;
379
495
  resourceAccessPermissions: Array<Scalars['String']>;
380
496
  };
497
+ export type TQuery_ExportOrganizationMembersArgs = {
498
+ organizationId: Scalars['ID'];
499
+ };
381
500
  export type TQuery_InvitationArgs = {
382
501
  where?: InputMaybe<TInvitationWhereInput>;
383
502
  };
@@ -527,6 +646,7 @@ export type TUser = TMetaData & {
527
646
  gravatarHash: Scalars['String'];
528
647
  id: Scalars['ID'];
529
648
  idTokenUserInfo?: Maybe<TIdTokenUserInfo>;
649
+ isAdminOfAnyOrganization: Scalars['Boolean'];
530
650
  language: Scalars['String'];
531
651
  lastModifiedAt: Scalars['String'];
532
652
  lastName: Scalars['String'];
@@ -675,6 +795,7 @@ export type TFetchLoggedInUserQuery = {
675
795
  launchdarklyTrackingTeam?: Array<string> | null;
676
796
  launchdarklyTrackingCloudEnvironment: string;
677
797
  defaultProjectKey?: string | null;
798
+ isAdminOfAnyOrganization: boolean;
678
799
  businessRole?: string | null;
679
800
  projects: {
680
801
  __typename?: 'ProjectQueryResult';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/application-shell-connectors",
3
- "version": "27.10.0",
3
+ "version": "27.11.0",
4
4
  "description": "Contains complementary tools for @commercetools-frontend/application-shell",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -51,10 +51,10 @@
51
51
  "tiny-warning": "1.0.3",
52
52
  "uuid": "14.0.1",
53
53
  "wait-for-observables": "1.0.3",
54
- "@commercetools-frontend/application-config": "^27.10.0",
55
- "@commercetools-frontend/browser-history": "^27.10.0",
56
- "@commercetools-frontend/constants": "^27.10.0",
57
- "@commercetools-frontend/sentry": "^27.10.0"
54
+ "@commercetools-frontend/application-config": "^27.11.0",
55
+ "@commercetools-frontend/browser-history": "^27.11.0",
56
+ "@commercetools-frontend/constants": "^27.11.0",
57
+ "@commercetools-frontend/sentry": "^27.11.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@apollo/client": "3.14.1",