@atlaskit/smart-hooks 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/i18n/en_ZZ.js +1 -0
  3. package/dist/cjs/version.json +1 -1
  4. package/dist/es2019/i18n/en_ZZ.js +1 -0
  5. package/dist/es2019/version.json +1 -1
  6. package/dist/esm/i18n/en_ZZ.js +1 -0
  7. package/dist/esm/version.json +1 -1
  8. package/dist/types/i18n/cs.d.ts +6 -6
  9. package/dist/types/i18n/da.d.ts +6 -6
  10. package/dist/types/i18n/de.d.ts +6 -6
  11. package/dist/types/i18n/en.d.ts +6 -6
  12. package/dist/types/i18n/en_GB.d.ts +6 -6
  13. package/dist/types/i18n/en_ZZ.d.ts +6 -6
  14. package/dist/types/i18n/es.d.ts +6 -6
  15. package/dist/types/i18n/et.d.ts +1 -1
  16. package/dist/types/i18n/fi.d.ts +6 -6
  17. package/dist/types/i18n/fr.d.ts +6 -6
  18. package/dist/types/i18n/hu.d.ts +6 -6
  19. package/dist/types/i18n/it.d.ts +6 -6
  20. package/dist/types/i18n/ja.d.ts +6 -6
  21. package/dist/types/i18n/ko.d.ts +6 -6
  22. package/dist/types/i18n/nb.d.ts +6 -6
  23. package/dist/types/i18n/nl.d.ts +6 -6
  24. package/dist/types/i18n/pl.d.ts +6 -6
  25. package/dist/types/i18n/pt_BR.d.ts +6 -6
  26. package/dist/types/i18n/pt_PT.d.ts +1 -1
  27. package/dist/types/i18n/ru.d.ts +6 -6
  28. package/dist/types/i18n/sk.d.ts +1 -1
  29. package/dist/types/i18n/sv.d.ts +6 -6
  30. package/dist/types/i18n/th.d.ts +6 -6
  31. package/dist/types/i18n/tr.d.ts +6 -6
  32. package/dist/types/i18n/uk.d.ts +6 -6
  33. package/dist/types/i18n/vi.d.ts +6 -6
  34. package/dist/types/i18n/zh.d.ts +6 -6
  35. package/dist/types/i18n/zh_TW.d.ts +6 -6
  36. package/dist/types/services/use-user-recommendations/index.d.ts +1 -1
  37. package/dist/types/types.d.ts +1 -1
  38. package/dist/types-ts4.5/i18n/cs.d.ts +18 -0
  39. package/dist/types-ts4.5/i18n/da.d.ts +18 -0
  40. package/dist/types-ts4.5/i18n/de.d.ts +18 -0
  41. package/dist/types-ts4.5/i18n/en.d.ts +18 -0
  42. package/dist/types-ts4.5/i18n/en_GB.d.ts +18 -0
  43. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +18 -0
  44. package/dist/types-ts4.5/i18n/es.d.ts +18 -0
  45. package/dist/types-ts4.5/i18n/et.d.ts +8 -0
  46. package/dist/types-ts4.5/i18n/fi.d.ts +18 -0
  47. package/dist/types-ts4.5/i18n/fr.d.ts +18 -0
  48. package/dist/types-ts4.5/i18n/hu.d.ts +18 -0
  49. package/dist/types-ts4.5/i18n/index.d.ts +36 -0
  50. package/dist/types-ts4.5/i18n/is.d.ts +7 -0
  51. package/dist/types-ts4.5/i18n/it.d.ts +18 -0
  52. package/dist/types-ts4.5/i18n/ja.d.ts +18 -0
  53. package/dist/types-ts4.5/i18n/ko.d.ts +18 -0
  54. package/dist/types-ts4.5/i18n/languages.d.ts +27 -0
  55. package/dist/types-ts4.5/i18n/nb.d.ts +18 -0
  56. package/dist/types-ts4.5/i18n/nl.d.ts +18 -0
  57. package/dist/types-ts4.5/i18n/pl.d.ts +18 -0
  58. package/dist/types-ts4.5/i18n/pt_BR.d.ts +18 -0
  59. package/dist/types-ts4.5/i18n/pt_PT.d.ts +8 -0
  60. package/dist/types-ts4.5/i18n/ro.d.ts +7 -0
  61. package/dist/types-ts4.5/i18n/ru.d.ts +18 -0
  62. package/dist/types-ts4.5/i18n/sk.d.ts +8 -0
  63. package/dist/types-ts4.5/i18n/sv.d.ts +18 -0
  64. package/dist/types-ts4.5/i18n/th.d.ts +18 -0
  65. package/dist/types-ts4.5/i18n/tr.d.ts +18 -0
  66. package/dist/types-ts4.5/i18n/uk.d.ts +18 -0
  67. package/dist/types-ts4.5/i18n/vi.d.ts +18 -0
  68. package/dist/types-ts4.5/i18n/zh.d.ts +18 -0
  69. package/dist/types-ts4.5/i18n/zh_TW.d.ts +18 -0
  70. package/dist/types-ts4.5/index.d.ts +3 -0
  71. package/dist/types-ts4.5/messages.d.ts +47 -0
  72. package/dist/types-ts4.5/services/use-function-usage-tracking/index.d.ts +5 -0
  73. package/dist/types-ts4.5/services/use-user-recommendations/analytics.d.ts +20 -0
  74. package/dist/types-ts4.5/services/use-user-recommendations/index.d.ts +21 -0
  75. package/dist/types-ts4.5/services/use-user-recommendations/ufoExperiences.d.ts +2 -0
  76. package/dist/types-ts4.5/types.d.ts +91 -0
  77. package/dist/types-ts4.5/utils/transform-recommendations-to-options/index.d.ts +5 -0
  78. package/package.json +10 -2
  79. package/report.api.md +1 -1
  80. package/tmp/api-report-tmp.d.ts +54 -0
@@ -0,0 +1,20 @@
1
+ import { AnalyticsEventPayload, CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import { UserSearchItem } from '@atlaskit/smart-common';
3
+ import { UseUserRecommendationsProps } from '../../types';
4
+ export declare const findUserPosition: (loadedUsers: UserSearchItem[], userId: string) => number;
5
+ export declare const createDefaultAttributes: (props: UseUserRecommendationsProps, renderId: string, sessionId: string, query: string) => {
6
+ context: string;
7
+ childObjectId: string | undefined;
8
+ containerId: string | undefined;
9
+ includeTeams: boolean | undefined;
10
+ maxNumberOfResults: number | undefined;
11
+ objectId: string | undefined;
12
+ preload: boolean | undefined;
13
+ principalId: string | undefined;
14
+ productKey: string;
15
+ queryLength: number;
16
+ renderId: string;
17
+ sessionId: string;
18
+ tenantId: string;
19
+ };
20
+ export declare const fireUserSelectedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, payloadAttributes: AnalyticsEventPayload) => import("@atlaskit/analytics-next").UIAnalyticsEvent;
@@ -0,0 +1,21 @@
1
+ import { EntityType, UserSearchItem } from '@atlaskit/smart-common';
2
+ import type { UseUserRecommendationsProps } from '../../types';
3
+ export declare const instrumentFailureOption: {
4
+ id: string;
5
+ name: string;
6
+ entityType: EntityType;
7
+ avatarUrl: string;
8
+ }[];
9
+ declare const useUserRecommendations: (props: UseUserRecommendationsProps) => {
10
+ recommendations: UserSearchItem[] | {
11
+ id: string;
12
+ name: string;
13
+ entityType: EntityType;
14
+ avatarUrl: string;
15
+ }[];
16
+ triggerSearchFactory: import("memoize-one").MemoizedFn<() => (query?: string) => void>;
17
+ selectUserFactory: import("memoize-one").MemoizedFn<() => (userId: string) => void>;
18
+ isLoading: boolean;
19
+ error: any;
20
+ };
21
+ export default useUserRecommendations;
@@ -0,0 +1,2 @@
1
+ import { ConcurrentExperience } from '@atlaskit/ufo';
2
+ export declare const UsersFetchedUfoExperience: ConcurrentExperience;
@@ -0,0 +1,91 @@
1
+ import type { UserSearchProductAttributes, UserSearchQuery } from '@atlaskit/smart-common';
2
+ export type UseUserRecommendationsProps = {
3
+ /**
4
+ * Base url override for downstream APIs.
5
+ * Note: there is a trend for browsers blocking cookies for cross-site resources.
6
+ * This prop is added for legacy reasons and will likely be removed in the future.
7
+ * https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more/
8
+ */
9
+ baseUrl?: string;
10
+ /**
11
+ * Context information for analytics. Eg: if the hook was consumed inside a ticket's comment, the childObjectId would be
12
+ * the ID of the comment and the ticket would be the objectId. Optional, but please provide if available.
13
+ */
14
+ childObjectId?: string;
15
+ /**
16
+ * The container Id to identify context. e.g. Jira: projectId. Confluence: spaceId. Bitbucket: repositoryId.
17
+ */
18
+ containerId?: string;
19
+ /**
20
+ * Time to debounce the suggestions fetching (in milliseconds). Defaults to 150ms.
21
+ */
22
+ debounceTimeMs?: number;
23
+ /**
24
+ * Identifier for informing the server on what experience the hook is powering.
25
+ * The server uses the fieldId to determine which model to utilize when
26
+ * generating suggestions.
27
+ * All fieldId's will be bucketed into a model that provides generic smart results,
28
+ * except "assignee", "mentions" which are specifically trained for Jira Assignee and
29
+ * @Mentions. For specifically trained models, please contact #help-smart-experiences.
30
+ */
31
+ fieldId: string;
32
+ /**
33
+ * Whether to include users in the result set (@default: true).
34
+ */
35
+ includeUsers?: boolean;
36
+ /**
37
+ * Whether to include groups in the resultset (@default: false).
38
+ */
39
+ includeGroups?: boolean;
40
+ /**
41
+ * Whether to include teams in the resultset (@default: false).
42
+ */
43
+ includeTeams?: boolean;
44
+ /**
45
+ * (@default: 25)
46
+ */
47
+ maxNumberOfResults?: number;
48
+ /**
49
+ * An identifier of the closest context object, e.g. issueId, pageId, pullRequestId.
50
+ * Used for analytics. Optional, but please include if available.
51
+ */
52
+ objectId?: string;
53
+ /**
54
+ * Preload the list of suggested users with an empty-query ('') search as soon as
55
+ * the hook is used.
56
+ * WARNING: please consider carefully before deciding to preload your suggestions
57
+ * as this will increase the load on the recommendations services (has caused HOTs).
58
+ * Please give #help-smart-experiences a ballpark on the expected request volume.
59
+ * (@default: false)
60
+ */
61
+ preload?: boolean;
62
+ /**
63
+ * AAID of the user interacting with the component.
64
+ * If not provided, server will extract principalId from the context header, assuming that the user is logged in
65
+ * when making the request. (@default: “context”)
66
+ */
67
+ principalId?: string;
68
+ /**
69
+ * Product-specific Attributes - you should pass in the attribute type that matches your current SupportedProduct.
70
+ * Currently we support additional attributes (BitbucketAttributes) for bitbucket and (ConfluenceAttributes) for Confluence.
71
+ */
72
+ productAttributes?: UserSearchProductAttributes;
73
+ /**
74
+ * Product identifier. If you are an NPF, please ensure your product has been onboarded with
75
+ * Cross-product user-search @see https://developer.atlassian.com/cloud/cross-product-user-search/
76
+ * If you are still waiting for CPUS, you can use the `people` productKey in the interim.
77
+ */
78
+ productKey: string;
79
+ /**
80
+ * Pass-through for CPUS. Refer to @see https://developer.atlassian.com/cloud/cross-product-user-search/rest/api-group-search/#api-group-search
81
+ * for detailed docs on parameters.
82
+ */
83
+ cpusSearchQuery?: UserSearchQuery;
84
+ /**
85
+ * Identifier for the product's tenant, also known as siteId or cloudId.
86
+ * If product is not tenanted, the convention is to provide the productKey
87
+ * as the tenantId (e.g. "bitbucket") but this may vary across products.
88
+ * Check with #help-smart-experiences.
89
+ */
90
+ tenantId: string;
91
+ };
@@ -0,0 +1,5 @@
1
+ import { IntlShape } from 'react-intl-next';
2
+ import { UserSearchItem } from '@atlaskit/smart-common';
3
+ import { OptionData } from '@atlaskit/user-picker';
4
+ declare const _default: (recommendations: UserSearchItem[], intl: IntlShape) => OptionData[];
5
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-hooks",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
@@ -10,6 +10,14 @@
10
10
  "module": "dist/esm/index.js",
11
11
  "module:es2019": "dist/es2019/index.js",
12
12
  "types": "dist/types/index.d.ts",
13
+ "typesVersions": {
14
+ ">=4.5 <4.9": {
15
+ "*": [
16
+ "dist/types-ts4.5/*",
17
+ "dist/types-ts4.5/index.d.ts"
18
+ ]
19
+ }
20
+ },
13
21
  "sideEffects": false,
14
22
  "atlaskit:src": "src/index.ts",
15
23
  "atlassian": {
@@ -52,7 +60,7 @@
52
60
  "enzyme": "^3.10.0",
53
61
  "fetch-mock": "^8.0.0",
54
62
  "react-dom": "^16.8.0",
55
- "typescript": "4.5.5",
63
+ "typescript": "~4.9.5",
56
64
  "wait-for-expect": "^1.2.0"
57
65
  },
58
66
  "techstack": {
package/report.api.md CHANGED
@@ -39,7 +39,7 @@ export const useUserRecommendations: (props: UseUserRecommendationsProps) => {
39
39
  entityType: EntityType;
40
40
  avatarUrl: string;
41
41
  }[];
42
- triggerSearchFactory: MemoizedFn<() => (query?: string | undefined) => void>;
42
+ triggerSearchFactory: MemoizedFn<() => (query?: string) => void>;
43
43
  selectUserFactory: MemoizedFn<() => (userId: string) => void>;
44
44
  isLoading: boolean;
45
45
  error: any;
@@ -0,0 +1,54 @@
1
+ ## API Report File for "@atlaskit/smart-hooks"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { EntityType } from '@atlaskit/smart-common';
8
+ import { IntlShape } from 'react-intl-next';
9
+ import { MemoizedFn } from 'memoize-one';
10
+ import { OptionData } from '@atlaskit/user-picker';
11
+ import { UserSearchItem } from '@atlaskit/smart-common';
12
+ import type { UserSearchProductAttributes } from '@atlaskit/smart-common';
13
+ import type { UserSearchQuery } from '@atlaskit/smart-common';
14
+
15
+ // @public (undocumented)
16
+ export const transformRecommendationsToOptions: (recommendations: UserSearchItem[], intl: IntlShape) => OptionData[];
17
+
18
+ // @public (undocumented)
19
+ export const useUserRecommendations: (props: UseUserRecommendationsProps) => {
20
+ recommendations: UserSearchItem[] | {
21
+ id: string;
22
+ name: string;
23
+ entityType: EntityType;
24
+ avatarUrl: string;
25
+ }[];
26
+ triggerSearchFactory: MemoizedFn<() => (query?: string) => void>;
27
+ selectUserFactory: MemoizedFn<() => (userId: string) => void>;
28
+ isLoading: boolean;
29
+ error: any;
30
+ };
31
+
32
+ // @public (undocumented)
33
+ type UseUserRecommendationsProps = {
34
+ baseUrl?: string;
35
+ childObjectId?: string;
36
+ containerId?: string;
37
+ debounceTimeMs?: number;
38
+ fieldId: string;
39
+ includeUsers?: boolean;
40
+ includeGroups?: boolean;
41
+ includeTeams?: boolean;
42
+ maxNumberOfResults?: number;
43
+ objectId?: string;
44
+ preload?: boolean;
45
+ principalId?: string;
46
+ productAttributes?: UserSearchProductAttributes;
47
+ productKey: string;
48
+ cpusSearchQuery?: UserSearchQuery;
49
+ tenantId: string;
50
+ };
51
+
52
+ // (No @packageDocumentation comment for this package)
53
+
54
+ ```