@atlaskit/link-datasource 1.15.3 → 1.15.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/analytics/constants.js +1 -1
  3. package/dist/cjs/hooks/useAssetsClient.js +71 -27
  4. package/dist/cjs/services/cmdbService.js +128 -28
  5. package/dist/cjs/services/cmdbService.utils.js +64 -0
  6. package/dist/cjs/ui/assets-modal/modal/index.js +73 -9
  7. package/dist/cjs/ui/assets-modal/modal/render-assets-content/index.js +25 -12
  8. package/dist/cjs/ui/assets-modal/search-container/index.js +2 -1
  9. package/dist/cjs/ui/assets-modal/search-container/object-schema-select/index.js +21 -63
  10. package/dist/es2019/analytics/constants.js +1 -1
  11. package/dist/es2019/hooks/useAssetsClient.js +39 -15
  12. package/dist/es2019/services/cmdbService.js +60 -14
  13. package/dist/es2019/services/cmdbService.utils.js +39 -0
  14. package/dist/es2019/ui/assets-modal/modal/index.js +70 -9
  15. package/dist/es2019/ui/assets-modal/modal/render-assets-content/index.js +24 -9
  16. package/dist/es2019/ui/assets-modal/search-container/index.js +2 -1
  17. package/dist/es2019/ui/assets-modal/search-container/object-schema-select/index.js +2 -25
  18. package/dist/esm/analytics/constants.js +1 -1
  19. package/dist/esm/hooks/useAssetsClient.js +72 -28
  20. package/dist/esm/services/cmdbService.js +128 -28
  21. package/dist/esm/services/cmdbService.utils.js +57 -0
  22. package/dist/esm/ui/assets-modal/modal/index.js +73 -9
  23. package/dist/esm/ui/assets-modal/modal/render-assets-content/index.js +24 -9
  24. package/dist/esm/ui/assets-modal/search-container/index.js +2 -1
  25. package/dist/esm/ui/assets-modal/search-container/object-schema-select/index.js +18 -60
  26. package/dist/types/hooks/useAssetsClient.d.ts +5 -1
  27. package/dist/types/services/cmdbService.utils.d.ts +9 -0
  28. package/dist/types/ui/assets-modal/modal/render-assets-content/index.d.ts +3 -2
  29. package/dist/types/ui/assets-modal/search-container/index.d.ts +1 -0
  30. package/dist/types/ui/assets-modal/search-container/object-schema-select/index.d.ts +2 -1
  31. package/dist/types-ts4.5/hooks/useAssetsClient.d.ts +5 -1
  32. package/dist/types-ts4.5/services/cmdbService.utils.d.ts +9 -0
  33. package/dist/types-ts4.5/ui/assets-modal/modal/render-assets-content/index.d.ts +3 -2
  34. package/dist/types-ts4.5/ui/assets-modal/search-container/index.d.ts +1 -0
  35. package/dist/types-ts4.5/ui/assets-modal/search-container/object-schema-select/index.d.ts +2 -1
  36. package/package.json +1 -1
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
5
  var _excluded = ["onChange", "onFocus"];
7
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
@@ -9,14 +8,12 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
9
8
  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; }
10
9
  /** @jsx jsx */
11
10
 
12
- import { useEffect, useState } from 'react';
13
11
  import { jsx } from '@emotion/react';
14
12
  import debounce from 'debounce-promise';
15
13
  import { useIntl } from 'react-intl-next';
16
14
  import { Field } from '@atlaskit/form';
17
15
  import { AsyncSelect } from '@atlaskit/select';
18
16
  import { layers } from '@atlaskit/theme/constants';
19
- import { useDatasourceAnalyticsEvents } from '../../../../analytics';
20
17
  import { useObjectSchemas } from '../../../../hooks/useObjectSchemas';
21
18
  import { objectSchemaKey } from '../../../../types/assets/types';
22
19
  import { FieldContainer } from '../styled';
@@ -46,74 +43,35 @@ export var selectInAModalStyleFixProps = {
46
43
  export var AssetsObjectSchemaSelect = function AssetsObjectSchemaSelect(_ref) {
47
44
  var value = _ref.value,
48
45
  workspaceId = _ref.workspaceId,
46
+ initialObjectSchemas = _ref.initialObjectSchemas,
49
47
  _ref$classNamePrefix = _ref.classNamePrefix,
50
48
  classNamePrefix = _ref$classNamePrefix === void 0 ? 'assets-datasource-modal--object-schema-select' : _ref$classNamePrefix;
51
- var _useState = useState(null),
52
- _useState2 = _slicedToArray(_useState, 2),
53
- defaultOptions = _useState2[0],
54
- setDefaultOptions = _useState2[1];
55
- var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
56
- fireEvent = _useDatasourceAnalyti.fireEvent;
57
49
  var _useIntl = useIntl(),
58
50
  formatMessage = _useIntl.formatMessage;
59
51
  var _useObjectSchemas = useObjectSchemas(workspaceId),
60
52
  fetchObjectSchemas = _useObjectSchemas.fetchObjectSchemas,
61
53
  objectSchemasLoading = _useObjectSchemas.objectSchemasLoading;
62
54
  var selectedObjectSchema = value ? objectSchemaToSelectOption(value) : undefined;
63
- useEffect(function () {
64
- var fetchInitialData = /*#__PURE__*/function () {
65
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
66
- var _yield$fetchObjectSch, objectSchemas, totalObjectSchemas;
67
- return _regeneratorRuntime.wrap(function _callee$(_context) {
68
- while (1) switch (_context.prev = _context.next) {
69
- case 0:
70
- _context.next = 2;
71
- return fetchObjectSchemas('');
72
- case 2:
73
- _yield$fetchObjectSch = _context.sent;
74
- objectSchemas = _yield$fetchObjectSch.objectSchemas;
75
- totalObjectSchemas = _yield$fetchObjectSch.totalObjectSchemas;
76
- // We only want to send modal ready event once after we've fetched the schema count
77
- fireEvent('ui.modal.ready.datasource', {
78
- schemasCount: totalObjectSchemas !== null && totalObjectSchemas !== void 0 ? totalObjectSchemas : 0,
79
- instancesCount: null
80
- });
81
- setDefaultOptions(mapObjectSchemasToOptions(objectSchemas));
82
- case 7:
83
- case "end":
84
- return _context.stop();
85
- }
86
- }, _callee);
87
- }));
88
- return function fetchInitialData() {
89
- return _ref2.apply(this, arguments);
90
- };
91
- }();
92
- if (defaultOptions === null) {
93
- fetchInitialData();
94
- }
95
- // eslint-disable-next-line react-hooks/exhaustive-deps
96
- }, []);
97
55
  var loadOptions = /*#__PURE__*/function () {
98
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(inputValue) {
99
- var _yield$fetchObjectSch2, objectSchemas;
100
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
101
- while (1) switch (_context2.prev = _context2.next) {
56
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(inputValue) {
57
+ var _yield$fetchObjectSch, objectSchemas;
58
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
59
+ while (1) switch (_context.prev = _context.next) {
102
60
  case 0:
103
- _context2.next = 2;
61
+ _context.next = 2;
104
62
  return fetchObjectSchemas(inputValue);
105
63
  case 2:
106
- _yield$fetchObjectSch2 = _context2.sent;
107
- objectSchemas = _yield$fetchObjectSch2.objectSchemas;
108
- return _context2.abrupt("return", mapObjectSchemasToOptions(objectSchemas));
64
+ _yield$fetchObjectSch = _context.sent;
65
+ objectSchemas = _yield$fetchObjectSch.objectSchemas;
66
+ return _context.abrupt("return", mapObjectSchemasToOptions(objectSchemas));
109
67
  case 5:
110
68
  case "end":
111
- return _context2.stop();
69
+ return _context.stop();
112
70
  }
113
- }, _callee2);
71
+ }, _callee);
114
72
  }));
115
73
  return function loadOptions(_x) {
116
- return _ref3.apply(this, arguments);
74
+ return _ref2.apply(this, arguments);
117
75
  };
118
76
  }();
119
77
  var debouncedLoadOptions = debounce(loadOptions, SEARCH_DEBOUNCE_MS);
@@ -129,16 +87,16 @@ export var AssetsObjectSchemaSelect = function AssetsObjectSchemaSelect(_ref) {
129
87
  validate: function validate(value) {
130
88
  return validateSchema(value);
131
89
  }
132
- }, function (_ref4) {
133
- var _ref4$fieldProps = _ref4.fieldProps,
134
- _onChange = _ref4$fieldProps.onChange,
135
- onFocus = _ref4$fieldProps.onFocus,
136
- restFieldProps = _objectWithoutProperties(_ref4$fieldProps, _excluded);
90
+ }, function (_ref3) {
91
+ var _ref3$fieldProps = _ref3.fieldProps,
92
+ _onChange = _ref3$fieldProps.onChange,
93
+ onFocus = _ref3$fieldProps.onFocus,
94
+ restFieldProps = _objectWithoutProperties(_ref3$fieldProps, _excluded);
137
95
  return jsx(AsyncSelect, _extends({
138
96
  autoFocus: true,
139
97
  classNamePrefix: classNamePrefix,
140
98
  isLoading: objectSchemasLoading,
141
- defaultOptions: defaultOptions !== null && defaultOptions !== void 0 ? defaultOptions : [],
99
+ defaultOptions: mapObjectSchemasToOptions(initialObjectSchemas),
142
100
  isSearchable: true,
143
101
  loadOptions: debouncedLoadOptions,
144
102
  placeholder: formatMessage(objectSchemaSelectMessages.placeholder),
@@ -3,7 +3,11 @@ import { AssetsDatasourceParameters } from '../ui/assets-modal/types';
3
3
  export type UseAssetsClientState = {
4
4
  workspaceId: string | undefined;
5
5
  workspaceError: Error | undefined;
6
- objectSchema: ObjectSchema | undefined;
6
+ existingObjectSchema: ObjectSchema | undefined;
7
+ existingObjectSchemaError: Error | undefined;
8
+ objectSchemas: ObjectSchema[] | undefined;
9
+ objectSchemasError: Error | undefined;
10
+ totalObjectSchemas: number | undefined;
7
11
  assetsClientLoading: boolean;
8
12
  };
9
13
  export declare const useAssetsClient: (initialParameters?: AssetsDatasourceParameters) => UseAssetsClientState;
@@ -0,0 +1,9 @@
1
+ export declare const mapFetchErrors: (error: any) => Error;
2
+ export declare const getStatusCodeGroup: (error: Error) => "1xx" | "3xx" | "4xx" | "5xx" | "unknown";
3
+ export declare class PermissionError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ export declare class FetchError extends Error {
7
+ statusCode: number;
8
+ constructor(statusCode: number, message?: string);
9
+ }
@@ -1,6 +1,7 @@
1
- /// <reference types="react" />
1
+ import { jsx } from '@emotion/react';
2
2
  import { DatasourceDataResponseItem, DatasourceResponseSchemaProperty, DatasourceTableStatusType } from '@atlaskit/linking-types';
3
3
  export interface RenderAssetsContentProps {
4
+ isFetchingInitialData: boolean;
4
5
  status: DatasourceTableStatusType;
5
6
  responseItems: DatasourceDataResponseItem[];
6
7
  visibleColumnKeys?: string[];
@@ -15,4 +16,4 @@ export interface RenderAssetsContentProps {
15
16
  onVisibleColumnKeysChange: (visibleColumnKeys: string[]) => void;
16
17
  modalRenderInstanceId: string;
17
18
  }
18
- export declare const RenderAssetsContent: (props: RenderAssetsContentProps) => JSX.Element;
19
+ export declare const RenderAssetsContent: (props: RenderAssetsContentProps) => jsx.JSX.Element;
@@ -4,6 +4,7 @@ import { jsx } from '@emotion/react';
4
4
  import type { ObjectSchema } from '../../../types/assets/types';
5
5
  export type InitialSearchData = {
6
6
  objectSchema?: ObjectSchema;
7
+ objectSchemas?: ObjectSchema[];
7
8
  aql?: string;
8
9
  };
9
10
  export interface SearchContainerProps {
@@ -4,6 +4,7 @@ import { ObjectSchema } from '../../../../types/assets/types';
4
4
  type AssetsObjectSchemaSelectProps = {
5
5
  value: ObjectSchema | undefined;
6
6
  workspaceId: string;
7
+ initialObjectSchemas: ObjectSchema[] | undefined;
7
8
  classNamePrefix?: string;
8
9
  };
9
10
  export declare const SEARCH_DEBOUNCE_MS = 350;
@@ -17,5 +18,5 @@ export declare const selectInAModalStyleFixProps: {
17
18
  };
18
19
  menuPortalTarget: HTMLElement;
19
20
  };
20
- export declare const AssetsObjectSchemaSelect: ({ value, workspaceId, classNamePrefix, }: AssetsObjectSchemaSelectProps) => jsx.JSX.Element;
21
+ export declare const AssetsObjectSchemaSelect: ({ value, workspaceId, initialObjectSchemas, classNamePrefix, }: AssetsObjectSchemaSelectProps) => jsx.JSX.Element;
21
22
  export {};
@@ -3,7 +3,11 @@ import { AssetsDatasourceParameters } from '../ui/assets-modal/types';
3
3
  export type UseAssetsClientState = {
4
4
  workspaceId: string | undefined;
5
5
  workspaceError: Error | undefined;
6
- objectSchema: ObjectSchema | undefined;
6
+ existingObjectSchema: ObjectSchema | undefined;
7
+ existingObjectSchemaError: Error | undefined;
8
+ objectSchemas: ObjectSchema[] | undefined;
9
+ objectSchemasError: Error | undefined;
10
+ totalObjectSchemas: number | undefined;
7
11
  assetsClientLoading: boolean;
8
12
  };
9
13
  export declare const useAssetsClient: (initialParameters?: AssetsDatasourceParameters) => UseAssetsClientState;
@@ -0,0 +1,9 @@
1
+ export declare const mapFetchErrors: (error: any) => Error;
2
+ export declare const getStatusCodeGroup: (error: Error) => "1xx" | "3xx" | "4xx" | "5xx" | "unknown";
3
+ export declare class PermissionError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ export declare class FetchError extends Error {
7
+ statusCode: number;
8
+ constructor(statusCode: number, message?: string);
9
+ }
@@ -1,6 +1,7 @@
1
- /// <reference types="react" />
1
+ import { jsx } from '@emotion/react';
2
2
  import { DatasourceDataResponseItem, DatasourceResponseSchemaProperty, DatasourceTableStatusType } from '@atlaskit/linking-types';
3
3
  export interface RenderAssetsContentProps {
4
+ isFetchingInitialData: boolean;
4
5
  status: DatasourceTableStatusType;
5
6
  responseItems: DatasourceDataResponseItem[];
6
7
  visibleColumnKeys?: string[];
@@ -15,4 +16,4 @@ export interface RenderAssetsContentProps {
15
16
  onVisibleColumnKeysChange: (visibleColumnKeys: string[]) => void;
16
17
  modalRenderInstanceId: string;
17
18
  }
18
- export declare const RenderAssetsContent: (props: RenderAssetsContentProps) => JSX.Element;
19
+ export declare const RenderAssetsContent: (props: RenderAssetsContentProps) => jsx.JSX.Element;
@@ -4,6 +4,7 @@ import { jsx } from '@emotion/react';
4
4
  import type { ObjectSchema } from '../../../types/assets/types';
5
5
  export type InitialSearchData = {
6
6
  objectSchema?: ObjectSchema;
7
+ objectSchemas?: ObjectSchema[];
7
8
  aql?: string;
8
9
  };
9
10
  export interface SearchContainerProps {
@@ -4,6 +4,7 @@ import { ObjectSchema } from '../../../../types/assets/types';
4
4
  type AssetsObjectSchemaSelectProps = {
5
5
  value: ObjectSchema | undefined;
6
6
  workspaceId: string;
7
+ initialObjectSchemas: ObjectSchema[] | undefined;
7
8
  classNamePrefix?: string;
8
9
  };
9
10
  export declare const SEARCH_DEBOUNCE_MS = 350;
@@ -17,5 +18,5 @@ export declare const selectInAModalStyleFixProps: {
17
18
  };
18
19
  menuPortalTarget: HTMLElement;
19
20
  };
20
- export declare const AssetsObjectSchemaSelect: ({ value, workspaceId, classNamePrefix, }: AssetsObjectSchemaSelectProps) => jsx.JSX.Element;
21
+ export declare const AssetsObjectSchemaSelect: ({ value, workspaceId, initialObjectSchemas, classNamePrefix, }: AssetsObjectSchemaSelectProps) => jsx.JSX.Element;
21
22
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "1.15.3",
3
+ "version": "1.15.4",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"