@atlaskit/smart-card 18.0.22 → 19.0.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.
- package/CHANGELOG.md +36 -0
- package/dist/cjs/client/index.js +6 -379
- package/dist/cjs/extractors/embed/index.js +2 -2
- package/dist/cjs/index.js +7 -13
- package/dist/cjs/state/actions/constants.js +1 -13
- package/dist/cjs/state/actions/index.js +20 -22
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +2 -2
- package/dist/cjs/state/config/index.js +2 -2
- package/dist/cjs/state/helpers.js +1 -9
- package/dist/cjs/state/hooks/usePrefetch.js +2 -2
- package/dist/cjs/state/index.js +4 -4
- package/dist/cjs/state/renderers/index.js +2 -2
- package/dist/cjs/state/store/index.js +5 -5
- package/dist/cjs/utils/mocks.js +2 -2
- package/dist/cjs/utils/test-utils.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/index.js +1 -214
- package/dist/es2019/extractors/embed/index.js +1 -1
- package/dist/es2019/index.js +4 -4
- package/dist/es2019/state/actions/constants.js +0 -6
- package/dist/es2019/state/actions/index.js +4 -4
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +1 -1
- package/dist/es2019/state/config/index.js +1 -1
- package/dist/es2019/state/helpers.js +0 -5
- package/dist/es2019/state/hooks/usePrefetch.js +1 -1
- package/dist/es2019/state/index.js +1 -1
- package/dist/es2019/state/renderers/index.js +1 -1
- package/dist/es2019/state/store/index.js +2 -2
- package/dist/es2019/utils/mocks.js +1 -1
- package/dist/es2019/utils/test-utils.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/index.js +1 -360
- package/dist/esm/extractors/embed/index.js +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/state/actions/constants.js +0 -6
- package/dist/esm/state/actions/index.js +4 -4
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +1 -1
- package/dist/esm/state/config/index.js +1 -1
- package/dist/esm/state/helpers.js +0 -5
- package/dist/esm/state/hooks/usePrefetch.js +1 -1
- package/dist/esm/state/index.js +1 -1
- package/dist/esm/state/renderers/index.js +1 -1
- package/dist/esm/state/store/index.js +2 -2
- package/dist/esm/utils/mocks.js +1 -1
- package/dist/esm/utils/test-utils.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/__tests_external__/page-objects/BaseCard.d.ts +1 -2
- package/dist/types/client/index.d.ts +1 -18
- package/dist/types/extractors/block/index.d.ts +1 -1
- package/dist/types/extractors/common/title-prefix/extractTitlePrefix.d.ts +1 -1
- package/dist/types/extractors/flexible/icon/extract-icon-renderer.d.ts +1 -1
- package/dist/types/extractors/flexible/icon/index.d.ts +1 -1
- package/dist/types/extractors/flexible/index.d.ts +1 -1
- package/dist/types/extractors/inline/index.d.ts +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/model/invoke-opts.d.ts +1 -14
- package/dist/types/state/actions/constants.d.ts +0 -6
- package/dist/types/state/actions/types.d.ts +2 -13
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +1 -2
- package/dist/types/state/config/index.d.ts +1 -1
- package/dist/types/state/helpers.d.ts +1 -3
- package/dist/types/state/hooks/useSmartLink.d.ts +6 -6
- package/dist/types/state/index.d.ts +3 -3
- package/dist/types/state/reducers/types.d.ts +1 -1
- package/dist/types/state/renderers/index.d.ts +1 -1
- package/dist/types/state/store/index.d.ts +2 -2
- package/dist/types/state/types.d.ts +1 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types/utils/analytics/analytics.d.ts +1 -1
- package/dist/types/utils/analytics/index.d.ts +1 -2
- package/dist/types/utils/performance.d.ts +1 -1
- package/dist/types/view/BlockCard/types.d.ts +1 -1
- package/dist/types/view/Card/types.d.ts +2 -3
- package/dist/types/view/FlexibleCard/types.d.ts +2 -2
- package/dist/types/view/FlexibleCard/utils.d.ts +1 -1
- package/dist/types/view/InlineCard/types.d.ts +1 -1
- package/package.json +3 -9
- package/dist/cjs/client/api.js +0 -119
- package/dist/cjs/client/errors.js +0 -55
- package/dist/cjs/client/types/index.js +0 -5
- package/dist/cjs/client/types/requests.js +0 -5
- package/dist/cjs/client/types/responses.js +0 -31
- package/dist/cjs/client/utils/environments.js +0 -47
- package/dist/cjs/providers/editor/index.js +0 -283
- package/dist/cjs/providers/editor/transformer.js +0 -84
- package/dist/cjs/providers/editor/types.js +0 -5
- package/dist/cjs/state/actions/helpers.js +0 -18
- package/dist/cjs/state/context/index.js +0 -34
- package/dist/cjs/state/context/provider.js +0 -74
- package/dist/cjs/state/context/types.js +0 -5
- package/dist/cjs/state/reducers/index.js +0 -89
- package/dist/cjs/state/store/types.js +0 -5
- package/dist/es2019/client/api.js +0 -38
- package/dist/es2019/client/errors.js +0 -19
- package/dist/es2019/client/types/index.js +0 -1
- package/dist/es2019/client/types/requests.js +0 -1
- package/dist/es2019/client/types/responses.js +0 -19
- package/dist/es2019/client/utils/environments.js +0 -33
- package/dist/es2019/providers/editor/index.js +0 -82
- package/dist/es2019/providers/editor/transformer.js +0 -53
- package/dist/es2019/providers/editor/types.js +0 -1
- package/dist/es2019/state/actions/helpers.js +0 -8
- package/dist/es2019/state/context/index.js +0 -14
- package/dist/es2019/state/context/provider.js +0 -51
- package/dist/es2019/state/context/types.js +0 -1
- package/dist/es2019/state/reducers/index.js +0 -74
- package/dist/es2019/state/store/types.js +0 -1
- package/dist/esm/client/api.js +0 -98
- package/dist/esm/client/errors.js +0 -40
- package/dist/esm/client/types/index.js +0 -1
- package/dist/esm/client/types/requests.js +0 -1
- package/dist/esm/client/types/responses.js +0 -19
- package/dist/esm/client/utils/environments.js +0 -33
- package/dist/esm/providers/editor/index.js +0 -257
- package/dist/esm/providers/editor/transformer.js +0 -73
- package/dist/esm/providers/editor/types.js +0 -1
- package/dist/esm/state/actions/helpers.js +0 -9
- package/dist/esm/state/context/index.js +0 -14
- package/dist/esm/state/context/provider.js +0 -50
- package/dist/esm/state/context/types.js +0 -1
- package/dist/esm/state/reducers/index.js +0 -69
- package/dist/esm/state/store/types.js +0 -1
- package/dist/types/client/api.d.ts +0 -5
- package/dist/types/client/errors.d.ts +0 -9
- package/dist/types/client/types/index.d.ts +0 -13
- package/dist/types/client/types/requests.d.ts +0 -9
- package/dist/types/client/types/responses.d.ts +0 -19
- package/dist/types/client/utils/environments.d.ts +0 -12
- package/dist/types/providers/editor/index.d.ts +0 -22
- package/dist/types/providers/editor/transformer.d.ts +0 -8
- package/dist/types/providers/editor/types.d.ts +0 -19
- package/dist/types/state/actions/helpers.d.ts +0 -2
- package/dist/types/state/context/index.d.ts +0 -8
- package/dist/types/state/context/provider.d.ts +0 -5
- package/dist/types/state/context/types.d.ts +0 -39
- package/dist/types/state/reducers/index.d.ts +0 -4
- package/dist/types/state/store/types.d.ts +0 -18
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Used to catch any other errors - not server-side.
|
|
2
|
-
export const isSuccessfulResponse = response => {
|
|
3
|
-
if (!response) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const hasSuccessfulStatus = response.status === 200;
|
|
8
|
-
const hasSuccessBody = ('body' in response);
|
|
9
|
-
return hasSuccessfulStatus && hasSuccessBody;
|
|
10
|
-
};
|
|
11
|
-
export const isErrorResponse = response => {
|
|
12
|
-
if (!response) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const hasStatus = response.status >= 200;
|
|
17
|
-
const hasErrorBody = ('error' in response);
|
|
18
|
-
return hasStatus && hasErrorBody;
|
|
19
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const devBaseUrl = 'https://api-private.dev.atlassian.com';
|
|
2
|
-
const stgBaseUrl = 'https://commerce-components-preview.dev.atlassian.com/gateway/api';
|
|
3
|
-
const prodBaseUrl = 'https://api-private.atlassian.com';
|
|
4
|
-
export const BaseUrls = {
|
|
5
|
-
dev: devBaseUrl,
|
|
6
|
-
development: devBaseUrl,
|
|
7
|
-
stg: stgBaseUrl,
|
|
8
|
-
staging: stgBaseUrl,
|
|
9
|
-
prd: prodBaseUrl,
|
|
10
|
-
prod: prodBaseUrl,
|
|
11
|
-
production: prodBaseUrl
|
|
12
|
-
};
|
|
13
|
-
export const getBaseUrl = envKey => {
|
|
14
|
-
// If an environment is provided, then use Stargate.
|
|
15
|
-
if (envKey) {
|
|
16
|
-
return envKey in BaseUrls ? BaseUrls[envKey] : prodBaseUrl;
|
|
17
|
-
} // Otherwise, use the current origin of the page.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return window.location.origin;
|
|
21
|
-
};
|
|
22
|
-
export const getResolverUrl = envKey => {
|
|
23
|
-
// If an environment is provided, then use Stargate directly for requests.
|
|
24
|
-
if (envKey) {
|
|
25
|
-
const baseUrl = getBaseUrl(envKey);
|
|
26
|
-
return `${baseUrl}/object-resolver`;
|
|
27
|
-
} else {
|
|
28
|
-
// Otherwise, we fallback to using the Edge Proxy to access Stargate,
|
|
29
|
-
// which fixes some cookie issues with strict Browser policies.
|
|
30
|
-
return '/gateway/api/object-resolver';
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export default BaseUrls;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// import setimmediate to temporary fix dataloader 2.0.0 bug
|
|
2
|
-
// @see https://github.com/graphql/dataloader/issues/249
|
|
3
|
-
import 'setimmediate';
|
|
4
|
-
import DataLoader from 'dataloader';
|
|
5
|
-
import { Transformer } from './transformer';
|
|
6
|
-
import { getResolverUrl, getBaseUrl } from '../../client/utils/environments';
|
|
7
|
-
import * as api from '../../client/api';
|
|
8
|
-
const BATCH_WAIT_TIME = 50;
|
|
9
|
-
export class EditorCardProvider {
|
|
10
|
-
constructor(envKey) {
|
|
11
|
-
this.baseUrl = getBaseUrl(envKey);
|
|
12
|
-
this.resolverUrl = getResolverUrl(envKey);
|
|
13
|
-
this.transformer = new Transformer();
|
|
14
|
-
this.requestHeaders = {
|
|
15
|
-
Origin: this.baseUrl
|
|
16
|
-
};
|
|
17
|
-
this.patternLoader = new DataLoader(keys => this.batchPatterns(keys), {
|
|
18
|
-
batchScheduleFn: callback => setTimeout(callback, BATCH_WAIT_TIME)
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async batchPatterns(keys) {
|
|
23
|
-
// EDM-2205: Batch requests in the case that user paste multiple links at
|
|
24
|
-
// once. This is so that only one /providers is being called.
|
|
25
|
-
const patterns = await this.fetchPatterns();
|
|
26
|
-
return keys.map(() => patterns);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async check(resourceUrl) {
|
|
30
|
-
try {
|
|
31
|
-
const endpoint = `${this.resolverUrl}/check`;
|
|
32
|
-
const response = await api.request('post', endpoint, {
|
|
33
|
-
resourceUrl
|
|
34
|
-
}, this.requestHeaders);
|
|
35
|
-
return response.isSupported;
|
|
36
|
-
} catch (err) {
|
|
37
|
-
// eslint-disable-next-line
|
|
38
|
-
console.error('failed to fetch /check', err);
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async fetchPatterns() {
|
|
44
|
-
try {
|
|
45
|
-
const endpoint = `${this.resolverUrl}/providers`;
|
|
46
|
-
const response = await api.request('post', endpoint, undefined, this.requestHeaders);
|
|
47
|
-
return response.providers.reduce((allSources, provider) => {
|
|
48
|
-
const providerSources = provider.patterns.map(pattern => pattern.source);
|
|
49
|
-
return allSources.concat(providerSources);
|
|
50
|
-
}, []);
|
|
51
|
-
} catch (err) {
|
|
52
|
-
// eslint-disable-next-line
|
|
53
|
-
console.error('failed to fetch /providers', err);
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async findPattern(url) {
|
|
59
|
-
if (!this.patterns) {
|
|
60
|
-
this.patterns = await this.patternLoader.load('providers');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return this.patterns ? this.patterns.some(pattern => url.match(pattern)) : false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async resolve(url, appearance) {
|
|
67
|
-
try {
|
|
68
|
-
let isSupported = (await this.findPattern(url)) || (await this.check(url));
|
|
69
|
-
|
|
70
|
-
if (isSupported) {
|
|
71
|
-
return this.transformer.toAdf(url, appearance);
|
|
72
|
-
}
|
|
73
|
-
} catch (e) {
|
|
74
|
-
// eslint-disable-next-line
|
|
75
|
-
console.warn(`Error when trying to check Smart Card url "${url} - ${e.prototype.name} ${e.message}`, e);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return Promise.reject(undefined);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
export const editorCardProvider = new EditorCardProvider();
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const isJiraRoadMap = url => url.match(/^https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/.*?\/roadmap\/?/);
|
|
2
|
-
|
|
3
|
-
const isPolarisView = url => url.match(/^https:\/\/.*?\/jira\/polaris\/projects\/[^\/]+?\/ideas\/view\/\d+$|^https:\/\/.*?\/secure\/JiraProductDiscoveryAnonymous\.jspa\?hash=\w+|^https:\/\/.*?\/jira\/polaris\/share\/\w+/);
|
|
4
|
-
|
|
5
|
-
const isJwmView = url => url.match(/^https:\/\/.*?\/jira\/core\/projects\/[^\/]+?\/(timeline|calendar|list|board)\/?/);
|
|
6
|
-
|
|
7
|
-
export class Transformer {
|
|
8
|
-
buildInlineAdf(url) {
|
|
9
|
-
return {
|
|
10
|
-
type: 'inlineCard',
|
|
11
|
-
attrs: {
|
|
12
|
-
url
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
buildBlockAdf(url) {
|
|
18
|
-
return {
|
|
19
|
-
type: 'blockCard',
|
|
20
|
-
attrs: {
|
|
21
|
-
url
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
buildEmbedAdf(url) {
|
|
27
|
-
return {
|
|
28
|
-
type: 'embedCard',
|
|
29
|
-
attrs: {
|
|
30
|
-
url,
|
|
31
|
-
layout: 'wide'
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
toAdf(url, appearance) {
|
|
37
|
-
if (isJiraRoadMap(url) || isPolarisView(url) || isJwmView(url)) {
|
|
38
|
-
return this.buildEmbedAdf(url);
|
|
39
|
-
} else {
|
|
40
|
-
switch (appearance) {
|
|
41
|
-
case 'inline':
|
|
42
|
-
return this.buildInlineAdf(url);
|
|
43
|
-
|
|
44
|
-
case 'block':
|
|
45
|
-
return this.buildBlockAdf(url);
|
|
46
|
-
|
|
47
|
-
case 'embed':
|
|
48
|
-
return this.buildEmbedAdf(url);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useContext, createContext } from 'react';
|
|
2
|
-
import { SmartCardProvider } from './provider';
|
|
3
|
-
export const SmartCardContext = /*#__PURE__*/createContext(undefined);
|
|
4
|
-
export function useSmartLinkContext() {
|
|
5
|
-
const context = useContext(SmartCardContext);
|
|
6
|
-
|
|
7
|
-
if (!context) {
|
|
8
|
-
throw Error('useSmartCard() must be wrapped in <SmartCardProvider>');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return context;
|
|
12
|
-
}
|
|
13
|
-
export { SmartCardProvider };
|
|
14
|
-
export default SmartCardContext;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useContext, useMemo } from 'react';
|
|
3
|
-
import { createStore } from 'redux';
|
|
4
|
-
import { cardReducer } from '../reducers';
|
|
5
|
-
import { SmartCardContext } from '.';
|
|
6
|
-
import CardClient from '../../client';
|
|
7
|
-
import { extractPreview } from '../../extractors/common/preview';
|
|
8
|
-
import { getUrl } from '../helpers';
|
|
9
|
-
export function SmartCardProvider({
|
|
10
|
-
storeOptions,
|
|
11
|
-
client: customClient,
|
|
12
|
-
authFlow: customAuthFlow,
|
|
13
|
-
children,
|
|
14
|
-
renderers
|
|
15
|
-
}) {
|
|
16
|
-
const parentContext = useContext(SmartCardContext);
|
|
17
|
-
const providerValue = useMemo(() => {
|
|
18
|
-
const {
|
|
19
|
-
initialState
|
|
20
|
-
} = storeOptions || {
|
|
21
|
-
initialState: {}
|
|
22
|
-
};
|
|
23
|
-
const client = customClient || new CardClient();
|
|
24
|
-
const store = createStore(cardReducer, initialState);
|
|
25
|
-
const authFlow = customAuthFlow || 'oauth2';
|
|
26
|
-
|
|
27
|
-
const getPreview = (url, platform) => {
|
|
28
|
-
const cardState = getUrl(store, url);
|
|
29
|
-
return cardState.details ? extractPreview(cardState.details.data, platform) : undefined;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
renderers,
|
|
34
|
-
store,
|
|
35
|
-
prefetchStore: {},
|
|
36
|
-
connections: {
|
|
37
|
-
client
|
|
38
|
-
},
|
|
39
|
-
config: {
|
|
40
|
-
authFlow
|
|
41
|
-
},
|
|
42
|
-
extractors: {
|
|
43
|
-
getPreview
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}, [customClient, customAuthFlow, storeOptions, renderers]);
|
|
47
|
-
return /*#__PURE__*/React.createElement(SmartCardContext.Provider, {
|
|
48
|
-
value: parentContext || providerValue
|
|
49
|
-
}, children);
|
|
50
|
-
}
|
|
51
|
-
export default SmartCardProvider;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import * as actions from '../actions/constants';
|
|
2
|
-
import { getStatus } from '../helpers';
|
|
3
|
-
const cardReducerMap = {
|
|
4
|
-
[actions.ACTION_PENDING]: (_state, {
|
|
5
|
-
type
|
|
6
|
-
}) => {
|
|
7
|
-
return {
|
|
8
|
-
status: type
|
|
9
|
-
};
|
|
10
|
-
},
|
|
11
|
-
[actions.ACTION_RESOLVING]: (state, {
|
|
12
|
-
type
|
|
13
|
-
}) => {
|
|
14
|
-
return { ...state,
|
|
15
|
-
status: type
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
[actions.ACTION_RESOLVED]: (state, {
|
|
19
|
-
type,
|
|
20
|
-
payload
|
|
21
|
-
}) => {
|
|
22
|
-
const nextDetails = payload;
|
|
23
|
-
const nextState = { ...state
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (nextDetails) {
|
|
27
|
-
nextState.status = getStatus(nextDetails);
|
|
28
|
-
nextState.details = nextDetails;
|
|
29
|
-
} else {
|
|
30
|
-
// Keep the pre-existing data in the store. If there
|
|
31
|
-
// is no data, the UI should handle this gracefully.
|
|
32
|
-
nextState.status = type;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return nextState;
|
|
36
|
-
},
|
|
37
|
-
[actions.ACTION_ERROR]: (state, {
|
|
38
|
-
type,
|
|
39
|
-
error
|
|
40
|
-
}) => {
|
|
41
|
-
return { ...state,
|
|
42
|
-
status: type,
|
|
43
|
-
error
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
[actions.ACTION_ERROR_FALLBACK]: (state, {
|
|
47
|
-
type,
|
|
48
|
-
error
|
|
49
|
-
}) => {
|
|
50
|
-
return { ...state,
|
|
51
|
-
status: type,
|
|
52
|
-
error
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
export const cardReducer = (state, action) => {
|
|
57
|
-
if (cardReducerMap[action.type]) {
|
|
58
|
-
const cardState = state[action.url]; // Card may have reached the same state on account of multiple of the same
|
|
59
|
-
// URL being present in an editor session. E.g. page with N links to one resource.
|
|
60
|
-
|
|
61
|
-
const hasSameStatus = cardState && cardState.status === action.type;
|
|
62
|
-
|
|
63
|
-
if (hasSameStatus) {
|
|
64
|
-
return state;
|
|
65
|
-
} else {
|
|
66
|
-
const nextState = cardReducerMap[action.type](cardState, action);
|
|
67
|
-
return { ...state,
|
|
68
|
-
[action.url]: nextState
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return state;
|
|
74
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/esm/client/api.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
-
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
10
|
-
|
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
-
|
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
-
|
|
15
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
-
|
|
17
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
-
|
|
19
|
-
var ALLOWED_RESPONSE_STATUS_CODES = [200, 401, 404];
|
|
20
|
-
export var NetworkError = /*#__PURE__*/function (_Error) {
|
|
21
|
-
_inherits(NetworkError, _Error);
|
|
22
|
-
|
|
23
|
-
var _super = _createSuper(NetworkError);
|
|
24
|
-
|
|
25
|
-
function NetworkError(error) {
|
|
26
|
-
_classCallCheck(this, NetworkError);
|
|
27
|
-
|
|
28
|
-
return _super.call(this, error);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return _createClass(NetworkError);
|
|
32
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
33
|
-
export function request(_x, _x2, _x3, _x4) {
|
|
34
|
-
return _request.apply(this, arguments);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function _request() {
|
|
38
|
-
_request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(method, url, data, headers) {
|
|
39
|
-
var requestConfig, response;
|
|
40
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
41
|
-
while (1) {
|
|
42
|
-
switch (_context.prev = _context.next) {
|
|
43
|
-
case 0:
|
|
44
|
-
requestConfig = _objectSpread({
|
|
45
|
-
method: method,
|
|
46
|
-
credentials: 'include',
|
|
47
|
-
headers: _objectSpread({
|
|
48
|
-
Accept: 'application/json',
|
|
49
|
-
'Cache-Control': 'no-cache',
|
|
50
|
-
'Content-Type': 'application/json'
|
|
51
|
-
}, headers)
|
|
52
|
-
}, data ? {
|
|
53
|
-
body: JSON.stringify(data)
|
|
54
|
-
} : {});
|
|
55
|
-
_context.prev = 1;
|
|
56
|
-
_context.next = 4;
|
|
57
|
-
return fetch(url, requestConfig);
|
|
58
|
-
|
|
59
|
-
case 4:
|
|
60
|
-
response = _context.sent;
|
|
61
|
-
|
|
62
|
-
if (!(response.ok || ALLOWED_RESPONSE_STATUS_CODES.includes(response.status))) {
|
|
63
|
-
_context.next = 9;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
_context.next = 8;
|
|
68
|
-
return response.json();
|
|
69
|
-
|
|
70
|
-
case 8:
|
|
71
|
-
return _context.abrupt("return", _context.sent);
|
|
72
|
-
|
|
73
|
-
case 9:
|
|
74
|
-
throw response;
|
|
75
|
-
|
|
76
|
-
case 12:
|
|
77
|
-
_context.prev = 12;
|
|
78
|
-
_context.t0 = _context["catch"](1);
|
|
79
|
-
|
|
80
|
-
if (!(typeof _context.t0 === 'string' || _context.t0 instanceof TypeError)) {
|
|
81
|
-
_context.next = 16;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
throw new NetworkError(_context.t0);
|
|
86
|
-
|
|
87
|
-
case 16:
|
|
88
|
-
throw _context.t0;
|
|
89
|
-
|
|
90
|
-
case 17:
|
|
91
|
-
case "end":
|
|
92
|
-
return _context.stop();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, _callee, null, [[1, 12]]);
|
|
96
|
-
}));
|
|
97
|
-
return _request.apply(this, arguments);
|
|
98
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
7
|
-
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
|
|
10
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
|
|
12
|
-
export var APIError = /*#__PURE__*/function (_Error) {
|
|
13
|
-
_inherits(APIError, _Error);
|
|
14
|
-
|
|
15
|
-
var _super = _createSuper(APIError);
|
|
16
|
-
|
|
17
|
-
function APIError(kind, hostname, message, type) {
|
|
18
|
-
var _this;
|
|
19
|
-
|
|
20
|
-
_classCallCheck(this, APIError);
|
|
21
|
-
|
|
22
|
-
_this = _super.call(this, "".concat(kind, ": ").concat(message));
|
|
23
|
-
_this.kind = kind;
|
|
24
|
-
_this.hostname = hostname;
|
|
25
|
-
_this.message = message;
|
|
26
|
-
_this.type = type;
|
|
27
|
-
_this.name = 'APIError'; // The error type received from the server.
|
|
28
|
-
|
|
29
|
-
_this.type = type; // The kind mapped to on the client.
|
|
30
|
-
|
|
31
|
-
_this.kind = kind; // The message received from the server.
|
|
32
|
-
|
|
33
|
-
_this.message = message; // The hostname of the URL which failed - do NOT log this (contains PII/UGC).
|
|
34
|
-
|
|
35
|
-
_this.hostname = hostname;
|
|
36
|
-
return _this;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return _createClass(APIError);
|
|
40
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Used to catch any other errors - not server-side.
|
|
2
|
-
export var isSuccessfulResponse = function isSuccessfulResponse(response) {
|
|
3
|
-
if (!response) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
var hasSuccessfulStatus = response.status === 200;
|
|
8
|
-
var hasSuccessBody = ('body' in response);
|
|
9
|
-
return hasSuccessfulStatus && hasSuccessBody;
|
|
10
|
-
};
|
|
11
|
-
export var isErrorResponse = function isErrorResponse(response) {
|
|
12
|
-
if (!response) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var hasStatus = response.status >= 200;
|
|
17
|
-
var hasErrorBody = ('error' in response);
|
|
18
|
-
return hasStatus && hasErrorBody;
|
|
19
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
var devBaseUrl = 'https://api-private.dev.atlassian.com';
|
|
2
|
-
var stgBaseUrl = 'https://commerce-components-preview.dev.atlassian.com/gateway/api';
|
|
3
|
-
var prodBaseUrl = 'https://api-private.atlassian.com';
|
|
4
|
-
export var BaseUrls = {
|
|
5
|
-
dev: devBaseUrl,
|
|
6
|
-
development: devBaseUrl,
|
|
7
|
-
stg: stgBaseUrl,
|
|
8
|
-
staging: stgBaseUrl,
|
|
9
|
-
prd: prodBaseUrl,
|
|
10
|
-
prod: prodBaseUrl,
|
|
11
|
-
production: prodBaseUrl
|
|
12
|
-
};
|
|
13
|
-
export var getBaseUrl = function getBaseUrl(envKey) {
|
|
14
|
-
// If an environment is provided, then use Stargate.
|
|
15
|
-
if (envKey) {
|
|
16
|
-
return envKey in BaseUrls ? BaseUrls[envKey] : prodBaseUrl;
|
|
17
|
-
} // Otherwise, use the current origin of the page.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return window.location.origin;
|
|
21
|
-
};
|
|
22
|
-
export var getResolverUrl = function getResolverUrl(envKey) {
|
|
23
|
-
// If an environment is provided, then use Stargate directly for requests.
|
|
24
|
-
if (envKey) {
|
|
25
|
-
var baseUrl = getBaseUrl(envKey);
|
|
26
|
-
return "".concat(baseUrl, "/object-resolver");
|
|
27
|
-
} else {
|
|
28
|
-
// Otherwise, we fallback to using the Edge Proxy to access Stargate,
|
|
29
|
-
// which fixes some cookie issues with strict Browser policies.
|
|
30
|
-
return '/gateway/api/object-resolver';
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export default BaseUrls;
|